Filter even numbers:
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const isEven = (x) => x % 2 === 0;
const evenNumbers = numbers.filter((x) => x % 2 === 0);
console.log(evenNumbers);
[ 2, 4, 6, 8, 10 ]
Filter words by length
const createLengthTest = (minLength) => (word) => word.length > minLength;
const longWords = words.filter(createLengthTest(5));
console.log(longWords);
[ 'goodbye', 'Antarctica' ]
Sources: https://www.linkedin.com/learning/learning-functional-programming-with-javascript-es6-plus