Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created October 9, 2015 00:34
Show Gist options
  • Save jasonbellamy/e6c0830a2b0974013e37 to your computer and use it in GitHub Desktop.
Save jasonbellamy/e6c0830a2b0974013e37 to your computer and use it in GitHub Desktop.
Imperative sum function that mistakenly tries to use the arguments object like an Array.
var sum = function () {
var result = 0;
arguments.forEach(function(number) {
result = result + number;
});
return result;
};
sum(1, 2, 3, 4, 5); // => "TypeError: arguments.forEach is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment