+ 1
screen output in html
Hello, I wanted to know if you help me please with this problem that I have. I want my code when I ask for a name on the screen and they write it, hello and the name appears. But if you do not write anything that appears, I would like you to say, say, hello again. Thanks if you help me https://code.sololearn.com/WO5cy4qLb3kd/?ref=app
4 odpowiedzi
+ 3
var user;
do
{
user = prompt("What is your name?");
if (user === null)
{
alert("Aborting...");
exit;
}
else if (user.trim() === "")
{
alert("Try again");
}
else
{
alert("Hello " + user + " ,Welcome");
}
}
while ((user !== null) && (user.trim() === ""));
+ 3
KINGDX put a great answer too ☺
+ 2
Replace your js by this :
________________________
var user = prompt("What is your name?");
while(user == null || user == ""){
user = prompt("gimme your name I said !");
}
alert( "Hello "+user+ " ,Welcome");
_______________________
Beware ! this is a stalker code, it won't let you through unless you have typed a name xD
+ 1
Thank you very much, apparently I was putting my cycles wrong, thanks Greetings is what I wanted