The problem here is JavaScript uses the +
symbol for both joining strings and adding numbers.
Because your statement has a string in it (the "Next entry "
part), it will assume it should treat everything as a string, so the 1
ends up being 11
- just as 8
would end up as 81
.
The trick is to give the JavaScript interpreter a hint as to what order it should do the operations. I see you've used spaces in your statement, but you need to use brackets:
node.warn("Next entry " + (i+1) );
With those brackets, it will first do the i+1
- where both sides are numbers, so it does numeric addition. It then does "Next entry " + <result of (i+1)>
where there is a String, so it does a string join.
I hope that clarifies it.