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

Overthinking the 5 quiz challenge?

if(question1.toUpperCase() === "moon" || question1.toUppercase() === "the moon") This line of code meant to accept the users input either if they type moon, MOON, or The moon. It seems to work, but then I don't get alert after answering the question, and I "closed" it with else statement as well. It might be easier to just use else if statement, but I'm wondering if there is any way to apply this code as I was trying. Thanks chaps for advance

1 Answer

The second expression in your condition (question1.toUpperCase === "the moon") will evaluate as true if the user enters either "the moon" or "THE MOON" but you state that it should accept if user input is "The moon" which only has one capital letter: 'T' so they would have to enter that phrase as "The moon" for the second condition to evaluate as true.