I am trying to get the number of items in an array then run a function X times.
Archiviert 3 years ago
8
8xaa
I am trying to get the number of items in an array then run a function that amount of times. Is this possible in JavaScript? I am storing the array in JSON.
This is the code I have set up for when there is only 1 app
```javascript
if (localStorage.getItem("repo")) {
repo = JSON.parse(localStorage.getItem("repo"));
create_app(repo.app.appName, repo.app.appIcon, repo.app.appId, repo.app.appUrl);
};
```
This is what the JSON looks like. The array I am trying to access is called "apps".
```json
{
"repoName": "repo_name",
"repoId": "unique_id",
"repoVer": "1",
"apps": [{
"appName": "first app name"
"appId": "app1",
"appUrl": "https://example.com",
"appIcon": "https://example.com/favicon.ico"
},
{
"appName": "second app name",
"appId": "app2",
"appUrl": "https://example.org",
"appIcon": "https://example.org/favicon.ico"
}]
}
```
