JSFiddle - React, Tailwind, and code Playground
by fairmutex
JavaScript
var arr = [1,2,3,4,5,6,7,8]
function predicate1(c){
return c<10;
}
function predicate2(c){
return c<8;
}
function every(a,predicate){
var k = a.filter(predicate);
if (k.length == a.length) return true;
else return false;
}
console.log(every(arr,predicate1));
console.log(every(arr,predicate2));
function some(a,predicate){
for (var i = 0 ; i < a.length;i++){
if(predicate(a[i]))
return true;
}
return false;
}
console.log(some(arr,predicate1));
console.log(some(arr,predicate2));