Hi,
I’m trying to nest an if-statement. I want to quiz the user with the question “What is the capital of Kenya?”. If they get it right, a message congratulating them will be displayed. If they get it wrong, I want to give them one more change. If they still get it wrong, I want to display a message that says “better luck next time”.
Here’s my code so far:
var question = “What is the capital of Kenya?”;
var answer = Nairobi;
var guess = window.prompt(question, “Enter your answer here”);
if (guess == answer) {
window.alert(“CONGRATULATIONS!!!”);
if (guess != answer)
guess = window.prompt(question, “Go on, have another go!”);
window.alert(“Second time lucky! Well done!);
}
else {
document.writeln(“I’m sorry, better luck next time”);
window.alert(“Unlucky mate!”);
}
I can’t get it to work… PLEASE HELP!!
What am i doing wrong?
Thanks ?