javascript code to loop through array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
javascript code to loop through array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
js loop through array
// ES6 for-of statement
for (const color of colors){
console.log(color);
}
// Array.prototype.forEach
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
// Sequential for loop
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
//Do something
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us