Skip to content

Instantly share code, notes, and snippets.

@TimBlock
Created January 15, 2016 12:00
Show Gist options
  • Save TimBlock/073d0c402155b46c2460 to your computer and use it in GitHub Desktop.
Save TimBlock/073d0c402155b46c2460 to your computer and use it in GitHub Desktop.
// Your code here.
function every(array,predicate){
for(var i = 0; i<array.length; i++){
if (!predicate(array[i]))
return false;
}
return true;
}
function some(array,predicate){
for(var i = 0; i<array.length; i++){
if (predicate(array[i]))
return true;
}
return false;
}
console.log(every([NaN, NaN, NaN], isNaN));
// → true
console.log(every([NaN, NaN, 4], isNaN));
// → false
console.log(some([NaN, 3, 4], isNaN));
// → true
console.log(some([2, 3, 4], isNaN));
// → false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment