0
How do I connect the if statement and the else to the prompt so I if a user types something and what he types will activate if
Or else
3 Antworten
+ 1
Just set a variable for the prompt.
For example, you want to challenge the user to answer "1+2" and if the user writes "3" in the prompt, it will say "Correct" and if not, it will say "wrong".
var sum = prompt ("What is the sum of 1+2?");
if (sum == "3"){
alert("Correct");
}else {
alert("Wrong");
}
I hope that answers your question.
+ 1
Indeed answered it
0
But what about the code "confirm"