Answers for "looping through a list in javascript"

48

javascript code to loop through array

var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Posted by: Guest on July-22-2019
5

iterate through list javascript

const array = ["hello", "world"];

for (item of array) {
	//DO THIS
}
Posted by: Guest on May-24-2020
1

iterate array in javascrpt

let array = [ 1, 2, 3, 4 ]; //Your array

for( let element of array ) {
	//Now element takes the value of each of the elements of the array
	//Do your stuff, for example...
  	console.log(element);
}
Posted by: Guest on May-14-2020

Code answers related to "looping through a list in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language