Skip to content

Instantly share code, notes, and snippets.

@gayanvirajith
Created July 9, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gayanvirajith/73eeb908ff856cf8e50fa5446f7830cb to your computer and use it in GitHub Desktop.
Save gayanvirajith/73eeb908ff856cf8e50fa5446f7830cb to your computer and use it in GitHub Desktop.
Node js average from command line argument
#!/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