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

my quiz score is not updating. Please help.

//question one:true var marbles = prompt("Question One. T or F: In Potion Explosion, The Key Items are marbles?"); if(marbles === true){ score += 1; alert("Correct! Your score is " +score+ ". With four more questions to go."); }else if{ score += 0; alert("Incorrect. Your score is " +score+ ". With four more questions to go."); }

I get a statement for the incorrect answer, but when I answer "true" It recognizes as a false statement. I do not know what is going wrong

3 Answers

Steven Parker
Steven Parker
231,269 Points

I notice there's an "else if", but with no conditional expression. That's probably intended to be a plain "else".

But the return value from "prompt" is a string, and will never be a boolean true. If you meant to check for the word "true" it needs quotes around it.

Chris Pulver
Chris Pulver
7,624 Points

Do you have additional code or files for this? (Also, it is easier to read if you use the markdown. See the cheatsheet next to the Answer button below.)

Currently I see a few problems:

  1. "question one:true". Is this a comment or code? If it's live code, there seems to be something missing (variable declaration, etc).
  2. Checking "marbles === true" means you are looking for the "true" boolean value. When a user enters information into a prompt, that is converted to a string. So you would likely be wanting to check for that instead.
  3. Your else if statement has no condition. Maybe this should just be an if...else instead of if...else if?
  4. Also in your else if, you are currently adding 0 to the score. Seems unnecessary to add zero, so likely something you could remove.

Yes, Inadvertently confused my if statements.