Filtre


  1. const filter = 

  2.   (fx, array) => array.reduce(

  3.     (acc, item) => fx(item) ? acc.concat(item) : acc, 

  4.   []);

  5. const greaterThan4 = (x) => x >= 4;

  6. const data   = [0, 1, 2, 3, 4, 5];

  7. let result = filter(greaterThan4, data);


code