Answers for "for each js example"

179

javascript foreach

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

for each functions javascript

//Am goinmg to practice the next big thing, using for.each function yo tripple iontegers in an array :)
  //for.each function is used to run a command on each number or string in an array 
  const theFigures = [2,4,5,6,7,8,9,12,23,45,68,31,90];
  const afterMath = (num) => {
    const theArray = [];
    num.forEach((n) => {
      const trippled = n*3;
      theArray.push(trippled);
    });
    return theArray;
  }
  console.log(afterMath(theFigures));
Posted by: Guest on September-15-2021
-2

javascript foreach

const Gpio = require('../onoff').Gpio;
const led = new Gpio(17, 'out');
Posted by: Guest on March-09-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language