Skip to content

Instantly share code, notes, and snippets.

@oliverjam
Created November 9, 2016 14:05
Show Gist options
  • Save oliverjam/35f0cc3bb63dda15f9398e5a2759b06c to your computer and use it in GitHub Desktop.
Save oliverjam/35f0cc3bb63dda15f9398e5a2759b06c to your computer and use it in GitHub Desktop.
EJ: C5 P4 created by oliverjam - https://repl.it/ETEO/2
function every(arr, f) {
for (let i = 0; i < arr.length; i++) {
if (!f(arr[i])) return false;
}
return true;
}
function some(arr, f) {
for (let i = 0; i < arr.length; i++) {
if (f(arr[i])) return true;
}
return false;
}
console.log(every([NaN, NaN, NaN], isNaN));
console.log(every([NaN, NaN, 4], isNaN));
console.log(some([NaN, 3, 4], isNaN));
console.log(some([2, 3, 4], isNaN));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment