Answers for "iterate over array javascript es6"

1

loop through arrays in es6

var sandwiches = [
	'tuna',
	'ham',
	'turkey',
	'pb&j'
];

sandwiches.forEach(function (sandwich, index) {
	console.log(index);
	console.log(sandwich);
});

// returns 0, "tuna", 1, "ham", 2, "turkey", 3, "pb&j"
Posted by: Guest on April-23-2020
1

JS iterate over an array

const beatles = [ "john", "paul", "ringo", "george"];

beatles.forEach((beatle) => {
  console.log(beatle);
});
Posted by: Guest on September-15-2021

Code answers related to "iterate over array javascript es6"

Code answers related to "Javascript"

Browse Popular Code Answers by Language