Hi guys, I've been programming quite a while in JS. But am a newbie to
Node. What a great app learnyounode is!
But this baffled me, perhaps someone cal explain this to me:
'strict mode';
var result;
for (var i = 2; i < process.argv.length; i++) {
result += Number(process.argv[i]);
}
console.log(result);
This always returned NaN. When I console log each iteration, I always end
up with an extra iteration which has the value of NaN. Adding them up
results into NaN.
But when I do this:
'strict mode';
*var result = 0;*
for (var i = 2; i < process.argv.length; i++) {
result += Number(process.argv[i]);
}
console.log(result);
Everything is fine and the program works as expected.
Who can enlighten me??
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/52ddf169-46c4-44b4-9548-37e7d37999de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.