I'm trying to get arguments ( fom second arg ) when running a js file in node then sum them.
var args = 0;
process.argv.reduce((a, b, c) => {
if (c > 1) {
console.log(+a + +b);
this.args += +a + +b;
}
return a
}, 0);
console.log(args)
In result I get 0 as sum when I run node exlearnyounode.js 12 4 6
but I'm expecting 22