javascript - Baby steps Node.js program prints indeterministic results -
I'm working on "learnyounode", the baby step of interactive Node.js tutorial.
is a program that accepts one or more number of commands line arguments and console (stdout).
Since I already know javascript, I thought it would be rather simple to print the sum of those numbers:
var sum = 0; For (var i = 2; i & lt; process.argv.length; i ++) {console.log ('add' + process.argv [i]); Zodiac + = number (process.argv [i]); } Console.log (sum) I can not see any problem in this piece of code, but the result seems unavoidable to me!
d: \ Repos \ GitHub \ damd \ learnyounode> Learnyounode run baby_steps.js 1 2 3 being added 32 150 d 45 being added 72 is being added 1 add: \ repos \ gitHub \ damd \ learnyounode & gt; 41 is being added 22 Run Running baby_steps.js Add learnyounode 85 Adding 38 186D: \ Repos \ GitHub \ damd \ learnyounode & gt; Learnyounode run baby_steps.js 10 20 30 60 25 being added 96 being added 24 being added 76 is being added 96 Added 21 Added 6 being 53 being added 51 being added 87 is being added 29 Add 2 Add Add to join 21 Add 28 Add 47 Adding 18 Adding 89 829 What's going on here? I am using Node.js v0.10.34 on Windows 7.
You would say good ol 'node executable to play your file: : learnyounode after its own arguments in the functionality (which you Do not know) without asking and ignoring their own arguments.
learnyounode instead of calling execution node baby_steps.js
run learnyounode baby_steps.js
Comments
Post a Comment