Q:

Write a JavaScript program to get a customized coalesce function that returns the first argument that returns true from the provided argument validation function

0

Write a JavaScript program to get a customized coalesce function that returns the first argument that returns true from the provided argument validation function.

All Answers

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

const coalesceFactory = valid => (...args) => args.find(valid);
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
console.log(customCoalesce(undefined, null, NaN, '', 'Waldo'));

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