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

kendall strautman
kendall strautman
7,114 Points

.toLowerCase not working properly in condition

My program runs great up until the 3rd question. It does not seem to be functioning properly because the score is not counted if the user inputs any variation of the word 'chinese' with upper or lower case letters, however if I remove the .toLowerCase and user inputs exactly as it states in string - "chinese" the score is counted - so I know that the .toLowerCase is the problem. Let me know if you see anything wrong with this code - focus on the third question because the others run fine. Thank you!

var continent = prompt("How many continents are there on the planet?");

var score = 0 

if (parseInt(continent) === 7){
  score += 1;
} 

var countries = prompt("How many countries are there on the planet?");

if (parseInt(countries) === 195){
  score += 1;
} 

var language = prompt("What is the most common language?");

if (language.toLowerCase === "chinese") {
  score += 1;
}

document.write ("Your total score is " + score + " out of 3");

3 Answers

I think there is something not right with your syntax. You forgot the end the .toLowerCase with a parenthesis. It should look like this I guess:

language.toLowerCase() === "chinese"

Hi there,

Have you tried having parentheses after the method name? .toLowerCase()

Steve.