Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
221,107 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,485 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
221,107 Points

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