Homework 3: Build a simple Node.js Program Content A Node.js program called sum.
ID: 3724773 • Letter: H
Question
Homework 3: Build a simple Node.js Program
Content
A Node.js program called sum.js that can accept 0 or more numbers on the command line and will return their total.
> node sum.js 1 2 3 4 5
The total is 15!
>node sum.js
The total is 0!
THE CODE WILL BE Rejection IF :
Your submission will be rejected for you to try again the next day if:
You use any third party JavaScript libraries
You don’t enable JavaScript’s strict mode
You use var instead of let
Your application doesn’t pass the ESLint configuration inside the Google Drive with no warnings or errors.
Explanation / Answer
'use strict';
let total = 0;
for (let j = 2; j < process.argv.length; j++) {
total += process.argv[j];
}
console.log('The total is ' + total);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.