Created
February 22, 2018 21:33
-
-
Save 6ui11em/cffb10b1782b00f0816b28fe764cbdf0 to your computer and use it in GitHub Desktop.
Arguments javascript vanilla #js #vanilla #javascript
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 add = function () { | |
var total = 0; | |
for (var i = 0; i < arguments.length; i++) { | |
total += arguments[i]; | |
} | |
return total; | |
}; | |
// Returns 1 | |
add(1); | |
// Returns 6 | |
add(1, 2, 3); | |
// Returns 0 | |
add(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment