JavaScript Foreach
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);
});
const array1 = ['a', 'b', 'c'];
array1.forEach((element) => {
console.log(element)
});
// expected output: "a"
// expected output: "b"
// expected output: "c"
const fruits = ['apple', 'orange', 'banana', 'mango'];
fruits.forEach((item, index)=>{
console.log(index, item)
});
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));
const numbers = [28, 77, 45, 99, 27];
numbers.forEach(number => {
console.log(number);
});