Hello I'm new to javascript and trying to run the following
var age = prompt("What is your age");
if (age < 19) {
document.write("You can't drink");
}
else if (age === 19) {
document.write("you can finally drink");
}
else (age > 19) {
document.write("you can already drink");
}
I can't seem to get anything to show up but if I change my code to remove the else statement and change the ===
to just ==
my code runs. This is how it looks like when it runs after I get rid of the else statement and ===
operator.
var age = prompt("What is your age");
if (age < 19) {
document.write("You can't drink");
}
else if (age == 19) {
document.write("you can finally drink");
}
I'm trying to get the first block of code to run but can't. The page is empty and no prompt shows up. Someone please help.