Answers for "javascript how do a loop through and array with foreach"

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
0

how to use the foreach fnction javascript loop through array

const names = ['Anthony','Stacey','Mason','Gracie','Koda','Nani'];

forEach(function(name) {
	console.log(name);
});
Posted by: Guest on April-16-2021

Code answers related to "javascript how do a loop through and array with foreach"

Code answers related to "Javascript"

Browse Popular Code Answers by Language