+ 1
How to make if else statement using prompt
I want to make a if else statement using prompt, like if someone enter a thing that i want, it will show this else show that.. Can anyone teach me how to do it?
7 Answers
+ 7
var input = prompt();
if(input == "something")
// do this
else
// do this
+ 2
There are many ways to do an if/else statement. Please narrow it down to a language or specific code question?
+ 1
Thanks for the help
+ 1
var person = prompt("Please enter your name", "Blugon");
if (person == null || person == "") {
txt = "User cancelled the prompt.";
} else {
txt = "Hello " + person + "! How are you today?";
}
alert(txt);
txt is String variable (but no declaration in JavaScript).
+ 1
What does the
(person == null || person == '")
Means?
0
person == null or person == ""
0
|| is or operator @Blugon