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

Allison Littman
Allison Littman
2,325 Points

I can't get my scorekeeper to work with this program. Please review my code. I may be mixing up C# and JavaScript.

var correctAnswers = 0;

var answer1 = prompt("What is Allison's favorite color?"); if (answer1.toUpperCase === "PINK") { correctAnswers += 1; console.log('Correct Answers = ' + correctAnswers); } var answer2 = prompt("What is Allison's favorite animal?"); if (answer2.toUpperCase === "MANATEE") { correctAnswers += 1; console.log('Correct Answers = ' + correctAnswers); } var answer3 = prompt("What is Allison's favorite breed of dog?"); if (answer3.toUpperCase === "CORGI") { correctAnswers += 1; console.log('Correct Answers = ' + correctAnswers); } var answer4 = prompt("What is Allison's favorite cocktail?"); if (answer4.toUpperCase === "BLOODY MARY") { correctAnswers += 1; console.log('Correct Answers = ' + correctAnswers); } var answer5 = prompt("What is Allison's favorite food?"); if (answer5.toUpperCase === "SUSHI") { correctAnswers += 1; console.log('Correct Answers = ' + correctAnswers); }

if (correctAnswers === 5) { alert("You've gotten " + correctAnswers + " questions right and have earned a gold crown!"); } else if (correctAnswers === 4 || correctAnswers === 3) { alert("You've gotten " + correctAnswers + " questions right and have earned a silver crown!");
} else if (correctAnswers === 2 || correctAnswers === 1) { alert("You've gotten " + correctAnswers + " questions right and have earned a bronze crown!"); } else { alert("You've gotten " + correctAnswers + " questions right and have earned no crown!"); }

1 Answer

Erwan EL
Erwan EL
7,669 Points

Hi, problem is that you didn't properly call your toUpperCase function.

Try that:

answer1.toUpperCase() === "PINK";