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

Having trouble with or operators

I am in the middle of the super conditional challenge, and for some reason this always comes up as incorrect. I know he will give me the answers in the next video, but I kind of want to have it all functional before I see it.

var questionTwo = prompt("What is the largest lake in the world"); if( questionTwo === 'caspian'.toUpperCase() || questionTwo === 'caspian sea'.toUpperCase() || questionTwo === 'the caspian sea'.toUpperCase() || questionTwo === 'the salty caspian sea'.toUpperCase() || questionTwo === 'salty caspian sea'.toUpperCase() ) { alert("that is correct! The salty Caspian Sea is the world's Largest Lake (by surface area): The salty Caspian Sea has the greatest surface area of any lake at 143,200 square miles."); correctAnswers += 1; } else { alert("that is incorrect. The salty Caspian Sea is the world's Largest Lake (by surface area): The salty Caspian Sea has the greatest surface area of any lake at 143,200 square miles."); wrongAnswers += 1; }

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Ok I'm only going to change one bit of your code so you can see why that answer will be correct and the others will be incorrect. Take a look at the first conditional statement and you should be able to see pretty clearly where your logic made a wrong turn! Hope this helps!

var questionTwo = prompt("What is the largest lake in the world");
    if( questionTwo.toUpperCase() === 'CASPIAN' || questionTwo === 'caspian sea'.toUpperCase() || questionTwo === 'the       caspian sea'.toUpperCase() || questionTwo === 'the salty caspian sea'.toUpperCase() || questionTwo === 'salty caspian sea'.toUpperCase() ) {
    alert("that is correct! The salty Caspian Sea is the world's Largest Lake (by surface area): The salty Caspian Sea has the greatest surface area of any lake at 143,200 square miles."); 
    correctAnswers += 1; }  else { 
    alert("that is incorrect. The salty Caspian Sea is the world's Largest Lake (by surface area): The salty Caspian Sea has the greatest surface area of any lake at 143,200 square miles."); 
wrongAnswers += 1; }

We have to take what the user puts in and convert that to uppercase. Then say if the uppercase version is equal to whatever it's supposed to be, count it correct. The way your code is now, the only way it will be correct is if the user enters the answer in all caps.

That was the answer I was looking for. Thanks so much!