Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created October 3, 2013 20:17
Show Gist options
  • Select an option

  • Save ericmoritz/6816459 to your computer and use it in GitHub Desktop.

Select an option

Save ericmoritz/6816459 to your computer and use it in GitHub Desktop.
function arraySum(i) {
return i.reduce(function(sum, x) {
if(x.reduce) {
return sum + arraySum(x);
} else if (typeof x === "number") {
return sum + x;
} else {
return sum;
}
}, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment