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

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!