Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Brian Platt
Brian Platt
5,009 Points

Can only get 0 crowns

In the quiz assignment I can only get it so that I achieve 0 crowns and I'm not sure how. I have gone over the code many times and have even simplified it to 3 questions from 5. Can anyone help? My code is pasted below

var correct = 0; //var answerOne = false; var answer1 = prompt("What color is a banana?"); if (answer1.toUpperCase === 'YELLOW') { //var answerOne = true; correct += 1; }

var answer2 = prompt("Bangkok is the capital of what country?"); if (answer2.toUpperCase === 'THAILAND') { correct += 1; }

var answer3 = prompt("What is the capital of America?"); if (answer3.toUpperCase === 'Washington') { correct += 1; }

document.write("<p>You got " + correct + " out of 3 questions correct.<p>");

if ( correct === 3 ) { document.write("You get a gold crown!"); } else if ( correct >= 2 ) { document.write("You get a silver crown!"); } else if ( correct >= 1 ) { document.write("You get a bronze crown!"); } else { document.write("Sorry, you get no crown!"); }

3 Answers

Close, the toUpperCase method needs two parenthesis at the end like so: answer.toUpperCase().

Also for your third question, Washington should be in all caps to match the comparison.

James Hudson
James Hudson
Courses Plus Student 9,683 Points

Kind of weird that this isn't being done in the video though... It's tough when you check your mistakes against the video and it's wrong in there too.

Lindsay has it correct. Add the parenthesis to your .toUpperCase() method and capitalize Washington and it works correctly.

Brian Platt
Brian Platt
5,009 Points

Wow, it's amazing what you don't see when you have been working on something for so long. Thanks Lindsay and David!