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 Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

When I make a conditional between two variables, it never outputs a true. Why is that?

I know my method wasn't the most efficient. Already saw the solution video and I know it wasn't necessary to make a variable out of the correct answer but I did it.

It should work and it doesn't.

if (submit1.toUpperCase === answer1){ correctAnswers += 1; }

The result is always false. Why is that?? Thanks in advance.

This is my code:


  1. Store correct answers
    • When quiz begins, no answers are correct */ const answer1 = "HTML"; const answer2 = "CSS"; const answer3 = "JAVASCRIPT"; const answer4 = "PRACTICE"; const answer5 = "PRACTICEX2";

// 2. Store the rank of a player

let rank; let correctAnswers = 0;

// 3. Select the <main> HTML element

const main = document.querySelector('main');


  1. Ask at least 5 questions
    • Store each answer in a variable
    • Keep track of the number of correct answers */

let submit1 = prompt ("What's the first thing you gotta learn to become a web developer?"); if (submit1.toUpperCase === answer1){ correctAnswers += 1; } console.log(submit1); console.log(correctAnswers);

let submit2 = prompt ("What's the second thing you gotta learn to become a web developer?"); if (submit2.toUpperCase === answer2){ correctAnswers += 1; } console.log(submit2);

let submit3 = prompt ("What's the third thing you gotta learn to become a web developer?"); if (submit3.toUpperCase === answer3){ correctAnswers += 1; } console.log(submit3);

let submit4 = prompt ("What's the fourth thing you gotta learn to become a web developer?"); if (submit4.toUpperCase === answer4){ correctAnswers += 1; } console.log(submit4);

let submit5 = prompt ("What's the fifth thing you gotta learn to become a web developer?"); if (submit5.toUpperCase === answer5){ correctAnswers += 1; } console.log(submit5);



  1. Rank player based on number of correct answers
    • 5 correct = Gold
    • 3-4 correct = Silver
    • 1-2 correct = Bronze
    • 0 correct = No crown */

if (correctAnswers == 0) { rank = "No"; } else if (correctAnswers == 1 || correctAnswers == 2) { rank = "Bronze"; } else if (correctAnswers == 3 || correctAnswers == 4) { rank = "Silver"; } else if (correctAnswers == 5) { rank = "Gold"; } // 6. Output results to the <main> element

main.innerHTML = <h1>According to the results: You earned ${rank} crown!</h1>

2 Answers

Have you tried adding parentheses to call the method? submit1.toUpperCase()

Yes! It was that syntax error. Thanks!