how to iterate through a list in javascript
snippet in javascript

how to iterate through a list in javascript

user7297

<script> 
index = 0; 
array = [ 1, 2, 3, 4, 5, 6 ]; 
  
array.forEach(myFunction); 
function myFunction(item, index) 
{ 
    console.log(item); 
}</script>

how to get value in array object value using for loop in javascript

user6584

const myArray = [{x:100}, {x:200}, {x:300}];

const newArray= myArray.map(element => element.x);
console.log(newArray); // [100, 200, 300]

javascript loop an array

user1485


  var i;
for (i = 0; i < cars.length; i++) { 
  text += cars[i] + "<br>";

 } 

iterate over array javascript

user6767

var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(myFunction);

function myFunction(value, index, array) {
  txt = txt + value + "<br>";
}

how to get value in array object value using for loop in javascript

user9540

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);