ForEach-function()

 let a = [12,3,4,5,5];

let num = [];

let no = a.forEach(function(n){

  if (n<10){

    console.log(n);

  }else{

    console.log(n);

  }

})

console.log(no);

The forEach() method calls a function once for each element in an array, in order.

Note: the function is not executed for array elements without values.

Comments

Popular posts from this blog

Hook and useState in React

Props and pass data from object list

React Map function