Created
June 26, 2019 20:06
-
-
Save RahmatSaeedi/255488bd0a2887d8f8553eedcdb2c231 to your computer and use it in GitHub Desktop.
This JS file sums the input argumets and prints the sum to the console
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
// This JS file sums the input argumets and prints the sum to the console | |
// Example | |
// node sum 1 2 | |
// 3 | |
// node sum 10 -100 12 | |
// 102 | |
// | |
// jshint esversion: 6 | |
const args = process.argv.slice(2); | |
let sum = 0; | |
args.forEach(n => sum += Number(n)); | |
console.log(sum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment