Answers for "for each in java script"

35

for each js

const fruits = ['mango', 'papaya', 'pineapple', 'apple'];

// Iterate over fruits below

// Normal way
fruits.forEach(function(fruit){
  console.log('I want to eat a ' + fruit)
});
Posted by: Guest on March-29-2020
31

js for each item do

let array = ['Item 1', 'Item 2', 'Item 3'];

array.forEach(item => {
	console.log(item); // Logs each 'Item #'
});
Posted by: Guest on February-20-2020
20

javascript for each loop

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

for each javascript

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

numbers.forEach((num) => {
  console.log(num);
});  // one   //two //three // four
Posted by: Guest on July-16-2020
6

foreach loop javascript

const numList = [1, 2, 3];

numList.forEach((number) => {
  console.log(number);
});
Posted by: Guest on October-05-2020
3

for each javascript

const movies = [
{name: "A New Hope", director: "George Lucas", release: "1977-05-25", episodeID: 4},
{name: "Attack of the Clones", director: "George Lucas", release: "2002-05-16", episodeID: 2},
{name: "Return of the Jedi", director: "Richard Marquand", release: "1983-05-25", episodeID: 6},
{name: "Revenge of the Sith", director: "George Lucas", release: "2005-05-19", episodeID: 3},
{name: "The Empire Strikes Back", director: "Irvin Kershner", release: "1980-05-17", episodeID: 5},
{name: "The Phantom Menace", director: "George Lucas", release: "1999-05-19", episodeID: 1}     
]
movies.forEach((movies) => {
  console.log(movies.name);
});
/*A New Hope
Attack of the Clones
Return of the Jedi
Revenge of the Sith
The Empire Strikes Back
The Phantom Menace*/
Posted by: Guest on November-07-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language