JavaScript para each
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
connect.sonveer
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
var colors = ['red', 'blue', 'green'];
colors.forEach(function(color) {
console.log(color);
});
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
arr.forEach(function(element){
console.log(element);
})
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});
var colors = ["red", "blue", "green"];
colors.forEach(function(color) {
console.log(color);
});
const a = ["a", "b", "c"];
for (const val of a) { // You can use `let` instead of `const` if you like
console.log(val);
}