Created
October 9, 2015 00:34
-
-
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.
This file contains hidden or 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
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