Answers for "iterate through array with for loop javascript /javascript.info"

72

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
15

javascript loop through array

var colors = ["red","blue","green"];
colors.forEach(function(color) {
  console.log(color);
});
Posted by: Guest on March-06-2020

Code answers related to "iterate through array with for loop javascript /javascript.info"

Code answers related to "Javascript"

Browse Popular Code Answers by Language