When I use the or
in the if
statement, it pretends like there is no ||
.
Example:
if (code !== "" || null) {
document.getElementById("person_name").innerHTML = "Welcome " + name + "!";
} else {
document.getElementById("person_name").innerHTML = "I'm sorry, but you didn't enter your name.";
}
I am using the window.prompt
in JavaScript to alert anyone to put their first name in the box and it should output it. If someone just presses enter without putting anything in the box, it should say, "I am sorry, but you didn't enter your name." If someone exits out of the prompt box, it should say the same thing.