Write a JavaScript function that returns true if the provided predicate function returns true for all elements in a collection, false otherwise

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

Write a JavaScript function that returns true if the provided predicate function returns true for all elements in a collection, false otherwise.

الأجوبة

const all = (arr, fn = Boolean) => arr.every(fn);
console.log(all([4, 2, 3], x => x > 1)); 
console.log(all([4, 2, 3], x => x < 1));
console.log(all([1, 2, 3])); 
هل كان المحتوى مفيد؟

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

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