Answers for "how to loop through an array and only apply attributes to certain items in the array"

4

javascript loop through array of objects

let arr = [object0, object1, object2];

for (let elm of arr) {
  console.log(elm);
}
Posted by: Guest on June-01-2020
4

javascript loop through array of objects

var people=[
  {first_name:"john",last_name:"doe"},
  {first_name:"mary",last_name:"beth"}
];
for (let i = 0; i < people.length; i++) { 
  console.log(people[i].first_name);
}
Posted by: Guest on June-17-2019
0

javascript loop through array of objects

yourArray.forEach(function (arrayItem) {
    var x = arrayItem.prop1 + 2;
    console.log(x);
});
Posted by: Guest on February-28-2020
0

javascript loop through array of objects

//Only to be used if you need the numbers
var array = new Array(item1,item2,item3)

for(i=0;i<array.length;i++){
  if(i==2){
    console.log(array[i])
  }
}
Posted by: Guest on March-07-2020

Code answers related to "how to loop through an array and only apply attributes to certain items in the array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language