So I'm having trouble here. It's an assignment, basically I ask a question of what 3+3 is and the user can put the right answer in... 6 and it will say "Correct!" If it's not a number, then it will say "please type in a number..." If it's 5 or 7 then it will say "Very close, try again" if it's anything other than 5 6 or 7 it wills say "incorrect" and if nothing is type in it should say "come on, you can do it." What am I doing wrong here???? Currently all it's doing is saying yes, 6 is correct! even when i type in a different number
var question;
question = window.prompt("What's the sum of 3+3?","");
question = parseFloat(question);
if (isNaN(question))
{
output= "Please enter a number";
}else if (question=6)
{
output="Yes " +question+" is correct!";
}else if (question=5){
output="Very close, try again!";
}else if (question=7){
output="Very close, try again!";
}else if (question=null){
output="Come on, you can do it!!";
}
else {output="Incorrect, Please try again"}
document.write(output);
Aucun commentaire:
Enregistrer un commentaire