Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

I can't get my else if to work

Hi, I don't know if anyone can help.

I've checked this over quite a few times and used some script validators to test and apparently there's an issue on line 38 (after the comment 'issue starts here').

I can't see a problem here. Can anyone help?

//START QUIZ, CORRECT HOLDS SCORE (CURRENTLY 0)

var correct = 0;

//ask question var q1 = prompt("What is the capital city of France?"); //IF ANSWER IS THIS, ADD 1 TO A SCORE if (q1.toUpperCase === "PARIS") { correct +=1; } //REPEAT PROCESS var q2 = prompt("What is the capital city of Italy?"); if (q2.toUpperCase === "ROME") { correct +=1; } var q3 = prompt("What is the capital city of Argentina?"); if (q3.toUpperCase === "BUENOS AIRES") { correct +=1; } var q4 = prompt("What is the capital city of Bolivia?"); if (q4.toUpperCase === "SUCRE") { correct +=1; } var q5 = prompt("What is the capital city of AUSTRALIA?"); if (q4.toUpperCase === "SYDNEY") { correct +=1; }

//ADD SCORE TOGETHER, GIVE CROWN DEPENDANT ON SCORE

document.write("<h2>You got " + correct + " out of five questions right.</h2>");

if (correct === 5); { document.write("<p>Well done, you've earnt a Golden Crown!</p>"); }

//ISSUE STARTS HERE else if (correct >= 3 ); { document.write("<p>Well done, you've earnt a Silver Crown!</p>"); }

else if (correct >= 1); { document.write("<p>Well done, you've earnt a Bronze Crown!</p>"); } else { document.write("<p>You 'win' a Wooden Spoon. You couldn't get any right? Not even one? Wow. Just wow.</p>"); }

2 Answers

Evgeniia Mas
Evgeniia Mas
4,452 Points

Hello, Jonathan. I think the problem is at least here : syntax of if is such
if (condition) { block of code to be executed if the condition is true } and NO SEMICOLON after braces as in your example if (correct === 5);

Thanks so much, I spent so long looking for that! Works much better now!

I really appreciate your taking the time to take a look. :)