Skip to content

Instantly share code, notes, and snippets.

@tarot
Created August 17, 2015 04:18
Show Gist options
  • Save tarot/2a9db73887a6fd39181c to your computer and use it in GitHub Desktop.
Save tarot/2a9db73887a6fd39181c to your computer and use it in GitHub Desktop.
you can't javascript under pressure #5
function(i) {
var fn = function(sum, e) {
if (typeof e === typeof 0) return sum + e;
if (e instanceof Array) return e.reduce(fn, sum);
return sum;
};
return i.reduce(fn, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment