1const avengers = ['thor', 'captain america', 'hulk'];
2avengers.forEach((item, index)=>{
3 console.log(index, item)
4})
1let words = ['one', 'two', 'three', 'four'];
2words.forEach((word) => {
3 console.log(word);
4});
5// one
6// two
7// three
8// four
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 new_array = old_array.map(function(e) {
2 e.data = e.data.split(',');
3 return e;
4});