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 Introducing Conditional Statements

Trouble with Challenge task 2. Add condition to trigger alert message if answer is correct.

var answer = prompt("What is the best programming language?");

if ( answer.toUpperCase() == 'JAVASCRIPT'){
  alert("You are correct");
}

After adding '.toUpperCase()' to the code, I get the error that task One's check failed. Task One was just the creation of the first line, which seems fine. I can't pass this challenge. Anyone else experience this?

Jeff Lauzon
Jeff Lauzon
21,972 Points

I just tried the challenge and passed. I am leaving out the last else statement. Give it a try :)

Your first line is correct. The challenge asks for the answer to be spelled as follows: 'JavaScript' NOT uppercase JAVASCRIPT. Try using the following:

var answer = prompt("What is the best programming language?");

if(answer === 'JavaScript') { alert("You are correct"); }

2 Answers

Jake Lundberg
Jake Lundberg
13,965 Points

The answer you are testing for is case sensitive in this example, so remove .toUpperCase() and change 'JAVASCRIPT' to 'JavaScript'.

That worked. Thanks for the reply

Jeff Lauzon
Jeff Lauzon
21,972 Points

Try using === instead of == when evaluating 'JAVASCRIPT'