boucle javascript via le tableau
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Grepper
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
let array = ['Item 1', 'Item 2', 'Item 3'];
for (let item of array) {
console.log(item);
}
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
const numbers = [1, 2, 3, 4]
numbers.forEach(number => {
console.log(number);
}
for (let i = 0; i < number.length; i++) {
console.log(numbers[i]);
}
var myStringArray = ["hey","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
//Do something
}
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));
array.forEach(item => console.log(item));
var numbers = [1, 2, 3, 4, 5];
numbers.forEach((Element) => console.log(Element));