Created
November 15, 2020 22:40
-
-
Save cihat/b57f54128e291ca3a4d346dcdd2041fd to your computer and use it in GitHub Desktop.
This file contains 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
function sum() { | |
var result = 0, | |
i = 0, | |
len = arguments.length; | |
while (i < len) { | |
result += arguments[i]; | |
i++; | |
} | |
return result; | |
} | |
console.log(sum(1, 2)); // 3 | |
console.log(sum(3, 4, 5, 6)); // 18 | |
console.log(sum(50)); // 50 | |
console.log(sum()); // 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment