Q:

Write a JavaScript program that takes a predicate and array, like Array.filter(), but only keeps x if pred(x) === false

0

 Write a JavaScript program that takes a predicate and array, like Array.filter(), but only keeps x if pred(x) === false

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const reject = (pred, array) => array.filter((...args) => !pred(...args));

console.log(reject(x => x % 2 === 0, [1, 2, 3, 4, 5]));

console.log(reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now