Skip to content

Instantly share code, notes, and snippets.

@phizaz
Created January 19, 2017 11:40
Show Gist options
  • Save phizaz/05349c98fd350a016f41e7388f0c0d68 to your computer and use it in GitHub Desktop.
Save phizaz/05349c98fd350a016f41e7388f0c0d68 to your computer and use it in GitHub Desktop.
Javascript Utils
/**
* returns true iff val equals every element in the list
*/
function all(list, val) {
if (list.length === 0) return false
const first = list[0]
if (first !== val) return false
for (const elem of list) {
if (first !== elem) return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment