Created
July 9, 2018 13:04
-
-
Save gayanvirajith/73eeb908ff856cf8e50fa5446f7830cb to your computer and use it in GitHub Desktop.
Node js average from command line argument
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
#!/usr/bin/env node | |
var sum = 0; | |
var count = 0; | |
process.argv.forEach(function (val, index, array) { | |
if (index > 1) { | |
sum += parseInt(val); | |
count++; | |
} | |
}); | |
console.log(sum/count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment