Loop an alert

how can i loop an alert if a prompt input is not made here is what i got

var name = prompt(‘What is your name?’);

if (name != null);
alert(“you didn’t tell me your name”);

im still learning but i want to get the grasp of this before keep going any further, now i was thinking on a while loop but the same thing with a while loop just go into an infinite loop after the alert, i wish to keep asking for a name if none is entered then move on with the next question and so on

You can’t type any input into an alert so you will want to rethink that, among other things, but that is a start.

No semi-colon in an if statement.

if (condition) {


When testing for null use the strict comparison:

if (name !== null)

However, you still have not checked for other input.

thanks for pointing out the ; i fixed that as soon as the text editor gave me the error, should i continue learning even if i cant complete this? is kind of an exercise that i want to challenge myself into but i can do a if/else statement i just cant figure out how to make it go again to ask for the name if nothing was typed, as far as i get is to the alert or i can change it to a prompt but if i dont put anything on that it just stop and dont keep asking… i guess the question is, am i to early for this?

Which lesson is this? Or, is it just your own effort to practice? We generally move personal questions to the Corner Bar if not directly related to the lesson.

Definitely. Concentrate on the actual lessons, and complete the exercises as close to what the instructions ask for as can be. No experimenting until after you pass the exercise. Some things we would like to do, early on, but are not well enough prepared. Complete the track then go back and review, and experiment till your heart’s content. Avoid trying to run when you are still attempting to get your feet under you.

ohh ok, yea it was a personal thing. thanks for your advise!

1 Like