Syntax question: Text For Your Name


#1

Hey Everybody,

Long time listener, first time caller. I'm having plenty of issues with the second loop, but I noticed that in the coding examples many of you have posted: (var i = 0; i < text.length ;i++) in your for loops, whereas I have it set to: (var i = 0; text.length < 7; i++) and the code passes up to creating the second loop. Or at least that's how I've been doing it up to now.

Is this incorrect? or just another way to go about doing things?

Thanks!


#2

This is a question about the first loop? So it seems.
I would use the first method:

(var i = 0; i < text.length ;i++)

The exercise uses regular expressions to check the code, but the only the code you are asked to create in the exercise, altering code from earlier exercises doesn't get checked again. Your loop has two problems: if the text variable holds a string which is longer then 7, it will never run, where as the text variable holds a string of less then 7 characters, the loop will run forever. (the condition will always be true)

Hope this helps


#3

It does. Thanks a bunch!