Skip to content

Instantly share code, notes, and snippets.

@bcrescimanno
Last active December 24, 2015 16:49
Show Gist options
  • Save bcrescimanno/6830318 to your computer and use it in GitHub Desktop.
Save bcrescimanno/6830318 to your computer and use it in GitHub Desktop.
BETTER solution to You Can't JavaScript Under Pressure Question 5
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