Answers for "array from for each"

131

javascript array foreach example

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

for each array javascript

var fruits = ["apple", "orange", "cherry"];
fruits.forEach(getArrayValues);

function getArrayValues(item, index) {
  console.log( index + ":" + item);
}
/*
result:
0:apple
1:orange
2:cherry
*/
Posted by: Guest on December-02-2020
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
0

Array Foreach Loop

const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach(element => {
  //Statement
  console.log(element);
});
Posted by: Guest on September-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language