Advertisement
nikolayneykov

Untitled

Nov 6th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  2.  
  3. const filtered = arr
  4.   .reduce((acc, el, i, arr) => {
  5.     if (el % 2 === 0) {
  6.       return [...acc, el];
  7.     }
  8.  
  9.     return acc;
  10.   }, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement