Last active
December 24, 2015 16:49
-
-
Save bcrescimanno/6830318 to your computer and use it in GitHub Desktop.
BETTER solution to You Can't JavaScript Under Pressure Question 5
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
function acc(pV, cV) { | |
if (cV instanceof Array) { | |
return pV + cV.reduce(acc, 0); | |
} else if (typeof cV == 'number') { | |
return pV + cV; | |
} | |
} | |
function arrSum(i) { | |
return i.reduce(acc, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment