Created
May 27, 2020 23:49
-
-
Save itsrachelfish/62485cc4eee4470fa6eef2a6136cb5c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let emilypi = ['hey', 'cool', 'list']; | |
function headOr(list, defaultValue) { | |
if(list[0] === undefined) { | |
return defaultValue; | |
} | |
return list[0]; | |
} | |
headOr(emilypi, 'wat'); | |
"hey" | |
headOr([], 'wat'); | |
"wat" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In haskell, this is