+ 1
Total beginner bere, could somebody explain why this if statement isnt working?
var name = prompt("Please tell me your name?"); if (name != null) { alert("Hello " + name + "! How are you?"); } else { alert("You didn\'t enter a name!"); } How would I check if the prompt string is 'null/empty'? Thanks!
2 Réponses
+ 5
use " "
+ 1
var name = prompt("Please tell me your name?");
if (name != "") {
alert("Hello " + name + "! How are you?");
} else {
alert("You didn\'t enter a name!");
}
/*Use this*/