hiryuu.com
Senior Squad
I have a problem...
I can seem to make a while function work
What I need is to validate the name, as long as the user inputs something everything's ok, but if the user inputs nothing, then I need a new prompt asking the user to enter his/her name.
(I know it's easier with an if statement, but the teacher wants it in a While, or do while form, and I don't get it (probably, because I haven't been going to class ).
Anyways, here's my code so far, which is wrong of course:
Right not it validates it the first time, but if they don't enter a name on the second prompt the loop stops
I can seem to make a while function work
What I need is to validate the name, as long as the user inputs something everything's ok, but if the user inputs nothing, then I need a new prompt asking the user to enter his/her name.
(I know it's easier with an if statement, but the teacher wants it in a While, or do while form, and I don't get it (probably, because I haven't been going to class ).
Anyways, here's my code so far, which is wrong of course:
Code:
var name = prompt("What is your name?", "")
while(name==null)
{
name = prompt("Please, tell us your name, so we can serve you better:", "")
}
Right not it validates it the first time, but if they don't enter a name on the second prompt the loop stops