interate through an array and create an object code example
Example 1: iterate through object array javascript
for (var key in array) {
var obj = myArray[key];
// ...
}
Example 2: loop through object in array javascript
var cars = [{name: 'Audi'}, {name: 'BMW'}, {name: 'Ferrari'}, {name: 'Mercedes'}, {name: 'Maserati'}];
for(var i = 0; i < cars.length; i++) {
console.log(cars[i].name);
}