+ 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

20th Apr 2018, 3:35 AM
Anthoni Rios
Anthoni  Rios - avatar
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() === ""));
20th Apr 2018, 9:34 AM
Emma
+ 3
KINGDX put a great answer too ☺
20th Apr 2018, 12:25 PM
Emma
+ 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
20th Apr 2018, 5:12 AM
CHMD
CHMD - avatar
+ 1
Thank you very much, apparently I was putting my cycles wrong, thanks Greetings is what I wanted
20th Apr 2018, 12:16 PM
Anthoni Rios
Anthoni  Rios - avatar