Created
September 22, 2013 16:54
-
-
Save terryp/6661820 to your computer and use it in GitHub Desktop.
Mildly pedantic way to take command line arguments, coerce into numbers and then add them up.
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
add = (nums) -> | |
result = 0 | |
for n in nums | |
result += n | |
return result | |
nums = [] | |
for arg in process.argv[2..] | |
arg = Number(arg) | |
nums.push(arg) | |
console.log(add(nums)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even more pedantic: