Answers for "for each example"

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
0

javascript for each

const emperors = [{
   name: 'D. Luffy',
   age: 10
},{
   name: 'Jhey',
   age: 30
}];

emperors.forEach(emperor => console.log(`${emperor.name} is ${emperor.age} years old `));
Posted by: Guest on May-24-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language