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

Devon Deason
Devon Deason
7,061 Points

What did I do to my code?? I had it working just fine.

So, I had my quiz working just fine. Then I went back in and added ".toUpperCase" so that capitalization would not determine whether or not an answer would be correct. Now, even if i type the answers in call caps, every response comes back as incorrect. The quiz worked like a charm until the addition of .toUpperCase. Where did I go wrong?

//GENERAL VALUES

var score = 0;
var question = 1;

//QUESTIONS

var question1 = prompt("Who is the Arrow? Question " + question + " of 5.");
if (question1.toUpperCase === 'OLIVER QUEEN') {
  score += 1;
  alert("That is correct! Your score is " + score + "."); 
} else {
  alert("Sorry, wrong answer.  Your score is " + score + ". Next question!")
}
question += 1;

var question2 = prompt("Who is the The Flash? Question " + question + " of 5.");
if (question2.toUpperCase === "BARRY ALLEN") {
   score += 1;
  alert("That is correct. Your score is " + score + ".");
} else {
  alert("Sorry, wrong answer. Your score is " + score + ". Next question!")
}
question += 1;

var question3 = prompt("Who is Deadpool? Question " + question + " of 5.");
if (question3.toUpperCase === "WAYDE WILSON") {
   score += 1;
  alert("That is correct. Your score is " + score + ".");
} else {
  alert("Sorry, wrong answer. Your score is " + score + ". Next question!")
}
question += 1;

var question4 = prompt("Who is the Spiderman? Question " + question + " of 5.");
if (question4.toUpperCase === "PETER PARKER") {
   score += 1;
  alert("That is correct. Your score is " + score + ".");
} else {
  alert("Sorry, wrong answer. Your score is " + score + ". Next question!")
}
question += 1;

var question5 = prompt("Who is the your daddy? Question " + question + " of 5.");
if (question5.toUpperCase === "AND WHAT DOES HE DO?") {
   score += 1;
  alert("That is correct. Your score is " + score + ".");
} else {
  alert("Sorry, wrong answer. Your score is " + score + ". IT'S GAME OVER MAN!")
}


//AWARDS
if (score <= 2) {
  document.write("<h2>You suck!</h2>");
} else if (score <= 4) {
  document.write("<h2>Well done!</h2>");
} else if (score === 5) {
  document.write("<h1>King of the world you are!</h1>");
          }

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Devon,

You are missing the () on the toUpperCase method. You need ex. question1.toUpperCase() === 'OLIVER QUEEN' for all of them.

:)

Colin Key
Colin Key
15,290 Points

.toUpperCase is a method and needs to be called as such. Add () to it in your if statements and you should be good to go.