Answers for "js for each item in array"

120

javascript foreach

const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
	console.log(index, item)
})
Posted by: Guest on April-27-2020
34

foreach javascript

let words = ['one', 'two', 'three', 'four'];
words.forEach((word) => {
  console.log(word);
});
// one
// two
// three
// four
Posted by: Guest on May-27-2020
1

js for each item in array

const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element));

// expected output: "a"
// expected output: "b"
// expected output: "c"
Posted by: Guest on January-15-2021
1

perform a function on each element of array javascript

var new_array = old_array.map(function(e) { 
  e.data = e.data.split(','); 
  return e;
});
Posted by: Guest on December-15-2019

Code answers related to "Javascript"

Browse Popular Code Answers by Language