What is a correct way to write a loop in JavaScript? code example
Example 1: javascript loop through array
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
Example 2: for loop javascript
var i;
for (i = 0; i < 10 ; i++) {
//do something
}