1const avengers = ['thor', 'captain america', 'hulk'];
2avengers.forEach((item, index)=>{
3 console.log(index, item)
4})
1array = [ 1, 2, 3, 4, 5, 6 ];
2for (index = 0; index < array.length; index++) {
3 console.log(array[index]);
4}
1const array1 = ['a', 'b', 'c'];
2
3array1.forEach(element => console.log(element));
4
5// expected output: "a"
6// expected output: "b"
7// expected output: "c"
1var colors = ["red", "blue", "green"];
2colors.forEach(function(color) {
3 console.log(color);
4});
1
2array.forEach(function calback(item, index, array)
3{
4
5 /* working codes here */
6
7 });
8