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

  • برمجة جافاسكربت java script
  • برمجة

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

الأجوبة

const coalesceFactory = valid => (...args) => args.find(valid);
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
console.log(customCoalesce(undefined, null, NaN, '', 'Waldo'));
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...