Answers for "js forEach list"

130

javascript foreach

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

javascript foreach

var colors = ['red', 'blue', 'green'];

colors.forEach(function(color) {
  console.log(color);
});
Posted by: Guest on June-27-2019
2

array.foreach

const arr = [0, 3, "hola", "hello", ";", true, [3, 6, 1]];
arr.forEach((element, index) => {
    console.log(element, index);
});

//output:

// 0 0
// 3 1
// hola 2
// hello 3
// ; 4
// true 5
// [3, 6, 1] 6
Posted by: Guest on April-06-2021
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
20

javascript foreach example

var colors = ["red", "blue", "green"];
colors.forEach(function(color) {
    console.log(color);
});
Posted by: Guest on July-19-2019
0

JavaScript Array Methods .forEach()

let days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
days.forEach(function log(day) {
  console.log(day)
})

// ES6 verzió óta lehetséges az ún. "array function" használata
// az eredmény ugyanaz lesz, mint az előző szintaxissal
days.forEach(day => {
  console.log(day)
});

// amikor a függvénytörzs egy sor, kapcsos zárójel és sortörés nélkül is
// írhatjuk a függvényt
days.forEach(day => console.log(day));
Posted by: Guest on May-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language