var question=prompt("What is your age?");
if (question == 14) {
alert("Coupon 1")
}
if (question == 21) {
alert("Coupon 2")
}
if (question == 30) {
alert("Coupon 3")
}
if (question == 50){
alert ("Coupon 4")
}
else {
alert("No Coupon")
}
If I enter age 14, it will display "Coupon 1" and then after it also displays "No Coupon". It does this for every if statement except the last one, age 50. If I enter age 50, I only get Coupon 4 and no "No Coupon". I do not understand why it does this.
Aucun commentaire:
Enregistrer un commentaire