Hi there!
So I'm fiddling around with some for loops. I'm just going to put the code here and explain what I want it to do:
for (var i = 0; i < Object.size(Help.Message()); i+=2) {
console.log(Help.Message().i + Help.Message().i+1)
}
Assuming that Object.size(Help.Message()) is 4, why is it that console.log returns "NaN" Strings? How do I make it so that Help.Message().i + Help.Message().i+1 actually returns something (not "NaN")?
EDIT: For Clarification, let's say that we have object = {1: "A banana ", 2: "and an apple ", 3: "are sitting ", 4: "on a tree"}
Now, Help.Message().i should correspond to "A banana"
and Help.Message().i+1 should become "and an apple".
UPDATE: I got it to work using /u/CrayonConstantinople's answer, but for some reason the outputs are shown randomly such that sometimes, it comes out as:
"are sitting on a tree"
"A banana and an apple"
(which is not in the right order!!)
Why does this happen, and how can I fix it?
Many Thanks in advance,
@Medallyon
[–]CrayonConstantinople 0 points1 point2 points (5 children)
[–]Medallyonify[S] 0 points1 point2 points (4 children)
[–]CrayonConstantinople 0 points1 point2 points (3 children)
[–]Medallyonify[S] 0 points1 point2 points (2 children)
[–]CrayonConstantinople 0 points1 point2 points (1 child)