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!

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

The conditional challenge

I don't know why at the end of this challenge even with 5 correct answers i'll still get 3 out of 5? I think something is wrong w output rank but i can't figure out . Thanks

// quiz begins, no answers correct var correct = 0;

var answer1 = prompt("Who was the first American in space?"); if (answer1.toUpperCase() === "ALAN SHEPARD" ) { correct += 1; } var answer2 = prompt("Who was the first president of United state?"); if (answer2.toUpperCase() === "GEORGE WASHINGTON" ) { correct += 1; } var answer3 = prompt("What was the first American car company?"); if (answer3.toUpperCase() === "FORD" ) { correct += 1; } var answer4 = prompt("What was the very first restaurant in America?"); if (answer4.toUpperCase === "DELMONICO") { correct += 1; } var answer5 = prompt("What was the very first war in America?"); if (answer5.toUpperCase === "AMERICAN WAR OF INDEPENDENCE" ) { correct += 1; } //Output results document.write("<p>You got " + correct + " out of 5 questions correct.</p>");

// Output rank if (correct === 5 ) { document.write("<p><strong>You earned a gold crown.</strong></p>"); } else if (correct === 3) { document.write("<p><strong>You earned a silver crown.</strong></p>"); } else if (correct === 2) { document.write("<p><strong>You earned bronze crown.</strong></p>"); } else { document.write("<p><strong>No crown for you.</strong></p>"); }

2 Answers

you are missing the () in the method toUpperCase() in answer4 and answer5.

I really appreciate it .