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

Kyle Gibbons
Kyle Gibbons
1,388 Points

I keep receiving 0 questions right, but I believe the code is correct?

var customer = 0;

var questionOne = prompt('Where is the greatest place to live?'); if ( questionOne.toUpperCase === 'SOUTH HERO' ) { customer += 1; } var questionTwo = prompt('What is the best programming language?'); if ( questionTwo.toUpperCase === 'JAVASCRIPT') { customer += 1; } var questionThree = prompt('What day is it today?'); if ( questionThree.toUpperCase === 'MONDAY' ) { customer += 1; } var questionFour = prompt('Where does Kyle Live?'); if ( questionFour.toUpperCase === 'DENVER') { customer += 1; } var questionFive = prompt("Is today alsmot over?"); if ( questionFive.toUpperCase === 'YES') { customer += 1; } if (customer === 5) { console.log( 'You got ' + customer + ' right' + ' and you receive a Gold Medal'); } else if (customer > 3) { console.log( 'You got ' + customer + ' right' + ' and you receive a Silver Medal'); } else if (customer > 1) { console.log( 'You got ' + customer + ' right' + ' and you receive a Bronze Medal'); } else { console.log('You got ' + customer + ' questions right!'); }

2 Answers

Steven Parker
Steven Parker
229,732 Points

To invoke the method "toUpperCase", you must place parentheses after it, even though it doesn't take an argument.

Example:

if ( questionOne.toUpperCase() === 'SOUTH HERO' ) { 

You will need to fix this on each of the 5 questions.

Also, when posting code please use the instructions in the Markdown Cheatsheet pop-up link below. :arrow_heading_down: And remember to skip a blank line before the code section.

Kyle Gibbons
Kyle Gibbons
1,388 Points

Thank you Steven, that was it. I will take a look at the Markdown Cheatsheet, I'm new to posting questions.

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

Lets look at your if statements:

if (customer === 5) { console.log( 'You got ' + customer + ' right' + ' and you receive a Gold Medal'); } else if (customer > 3) { console.log( 'You got ' + customer + ' right' + ' and you receive a Silver Medal'); } else if (customer > 1) { console.log( 'You got ' + customer + ' right' + ' and you receive a Bronze Medal'); } else { console.log('You got ' + customer + ' questions right!'); } You need to change if (customer > 1) to include the number 1 & 2. Here you only are catching 2. Clue: use ||

If you cant figure it out I will help you with the rest...try it out first.

Steven Parker
Steven Parker
229,732 Points

If the bronze medal is intended for 2 or 3 right answers, the code is correct.