+ 2
Help! Why this code not work!? What wrong is it?
I'm prompting user to enter string for username. But if they press cancel, it gets sent as null. How do I make it change to a default username ("Steve") if they press cancel/if it returns null? var myUsername = prompt("Enter username", "Steve"); document.write(myUsername); Please see code and tell me what I did wrong? https://code.sololearn.com/W9T03UNv5jcH/?ref=app
3 Réponses
+ 8
replace your code with this 👇
var myUsername = prompt("Enter username", "Steve");
if(myUsername == null)
myUsername = "Steve";
document.write(myUsername);
+ 7
My Pleasure !!!😊😊 Andre Daniel
+ 1
It worked! Thank you Mohammad Amir Aqeel 😊