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

John Barhorst
John Barhorst
9,648 Points

My === is accepting an answer that isn't exactly right.

When typing in and testing answers to this, I slipped up and typed christma, no 's', and it still checked out as right. Wondering if it's an error on my part or just a behavioral thing in javascript?

var question5 = prompt("What is the worst delivery season?");

if (question5.toLowerCase() === "winter" || "christmas") {
  alert("That's correct!");
  score += 1;
} else {
  alert("Christmas and the winter are the worst!");
}

2 Answers

John Barhorst
John Barhorst
9,648 Points

I just tested another question I had on there where I used || wrong. I have answered my own issue!

Hunter G
Hunter G
6,612 Points

John, you must include the variable & toLowerCase() function on both sides of the '||' in the statement. should look like this:

if (question5.toLowerCase() === "winter" || question5.toLowerCase() === "christmas") {

}