what is the modern syntax for iterating through array using for loop in javascript code example
Example 1: how to get value in array object value using for loop in javascript
const people = [ {name: "john", age:23},
{name: "john", age:43},
{name: "jim", age:101},
{name: "bob", age:67} ];
const john = people.find(person => person.name === 'john');
console.log(john);
Example 2: how to get value in array object value using for loop in javascript
const myArray = [{x:100}, {x:200}, {x:300}];
const sum = myArray.map(element => element.x).reduce((a, b) => a + b, 0);
console.log(sum);
const average = sum / myArray.length;
console.log(average);
Example 3: what is the modern syntax for iterating through array using for loop in javascript
let friends=["jony","tom","Tejas"];
friends.forEach(
function f(i){
console.log(i);
}
)