loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
javascript loop through array
let my_array = [1, 2, 3, 4, 5];
// standard for loop
for(let i = 0; i < my_array.length; i++) {
console.log(my_array[i]) // 1 2 3 4 5 6
}
// for and of method
for(let i of my_array) {
console.log(i)
}
/*
Results:
1 2 3 4 5
1 2 3 4 5
(From both methods)
*/
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