Answers for "for each value in array"

35

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
23

foreach jas

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

array1.forEach(element => console.log(element));
Posted by: Guest on January-10-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
8

javascript foreach

let numbers = ['one', 'two', 'three', 'four'];

numbers.forEach((num) => {
  console.log(num);
});  // one   //two //three // four
Posted by: Guest on July-16-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

Code answers related to "Javascript"

Browse Popular Code Answers by Language