FILTER function

 let arr = [1, 2, 44, 6, 76, 89];

let ans = arr.filter((el) => {
  return el % 2 == 0;
});
console.log(ans);

let ans2 = arr.filter((el) => {
  return el % 2 != 0;
});
console.log(ans2);

let ans3 = arr.filter((el) => {
  return el > 5;
});
console.log(ans3);


Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code