<script> index = 0; array = [ 1, 2, 3, 4, 5, 6 ]; array.forEach(myFunction); function myFunction(item, index) { console.log(item); }</script>
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);
const myArray = [{x:100}, {x:200}, {x:300}]; const sum = myArray.map(element => element.x).reduce((a, b) => a + b, 0); console.log(sum); // 600 = 0 + 100 + 200 + 300 const average = sum / myArray.length; console.log(average); // 200
let friends=["jony","tom","Tejas"]; friends.forEach( function f(i){ console.log(i); } )