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

Norman Gallardo
Norman Gallardo
3,806 Points

My program works for the most part but I tried to add an 'or' condition and it seems to not be working

Here is a piece of my code where I added the 'or' condition, but the it seems the user can enter anything (i.e. numbers or letters) for that question and it will still come out correct. Am I using it incorrectly? Thanks in advance:

//Question Four var questionFour = prompt("In Disneyland, which land Space Mountain located?") if (questionFour.toUpperCase()=== 'TOMORROW LAND' || 'TOMORROWLAND') { correctAnswers +=1
} else { alert("Nope! The correct answer is Tomorrow Land"); }

2 Answers

Steven Parker
Steven Parker
231,269 Points

Your expression is incomplete, and a string that's not empty is considered "truthy".

A complete expression might look like this:

questionFour.toUpperCase() === 'TOMORROW LAND' || questionFour.toUpperCase() === 'TOMORROWLAND'
Norman Gallardo
Norman Gallardo
3,806 Points

That's what was missing! Thanks!