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
Post a Comment