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 trialTony Tang
1,692 PointsTrouble 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?
2 Answers
Jake Lundberg
13,965 PointsThe answer you are testing for is case sensitive in this example, so remove .toUpperCase() and change 'JAVASCRIPT' to 'JavaScript'.
Tony Tang
1,692 PointsThat worked. Thanks for the reply
Jeff Lauzon
21,972 PointsTry using === instead of == when evaluating 'JAVASCRIPT'
Jeff Lauzon
21,972 PointsJeff Lauzon
21,972 PointsI 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"); }