How to return an array with even numbers from existing array in Node.js

1 Answer

0 votes
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];

const even = arr.filter(n => n % 2 === 0)

console.log(even); 

  
  
  
  
/*
run:
  
[
   2,  4,  6, 8,
  10, 12, 14
]
  
*/

 



answered Jun 5, 2022 by avibootz
...