I had a spent the better part of a day trying to solve this problem, and although I eventually did manage to make the for loop work I'm hoping somebody can help clarify why it works.
for (var i = 0; i < text.length; i++)
So if I'm understanding correctly we have 3 statements in the for loop:
- The starting condition - var i =0;
- The stopping condition - i < text.length;
- The variable change statement - i++
Now, would I be correct in saying that the stopping condition is something that is essentially a boolean, and the for loop runs only while the statement is true?
Up until this point I had thought that the stopping condition was more like a check on when to stop, or in other words, the condition would only stop once the condition became true.