0
The if statement for JAVASCRIPT isn't working.
I want it to display an alert depending on the input of a prompt, but it only displays the first one, both, or none. I tried the else if and it didn't work. I couldn't find this problem in the current discussion, or the answere in the lessons or intro to JS. Please Help
4 Answers
+ 8
Share your code link here and detailed description of what you are working on.
+ 1
let x = 5;
if (x > 0) {
console.log("x is positive");
} else {
console.log("x is not positive");
}
the condition x > 0 is true,
so the code within the first block will be executed and âx is positiveâ will be logged to the console.
If your if statement isnât working, there could be a few reasons.
0
Var select = prompt("type A for option 1 type B for option 2")
If(select === "A"){
alert("You have selected option 1")
}
If (select === "B"){
alert("you have selected option 2")
}
0
Just updating: it must have been a glitch because it is working now