Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with Node.js Please correct error ======================== \'eslint -c .esl

ID: 3728440 • Letter: H

Question

Help with Node.js Please correct error

========================

'eslint -c .eslintrc.js sum.js'
'use strict'
let total = 0;
const cmds = process.argv;
for (let i = 2; i < cmds.length; i++) {
total += cmds[i] - 0;

}
console.log("The total is" + total + "!");

===================================

Please fix my code and pass it with Eslint(version 6)

https://eslint.org/demo

Messages Fixed Code 4:14 -'process' is not defined. (no-undef) 9:1 - Unexpected console statement. (no-console) 9:1- 'console' is not defined. (no-undef)

Explanation / Answer

fixed code is below:

there is no console on that website so run with console:

'eslint -c .eslintrc.js sum.js'
'use strict'
var total = 0;
var cmds = process.argv;
for (var i = 2; i < cmds.length; i++) {
    total += cmds[i] - 0;

}
console.log("The total is " + total + "!");

sample output:

The total is 0!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote