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 trialPrabhuram Kalathingal
1,057 PointsMy answer is correct but the editor keeps on showing "oh it looks like Task 1 is no longer passing", ??
var answer=prompt("What is the best programming language?"); if (answer.toUpperCase() === "JAVASCRIPT" ) { document.write('You are correct'); }
var answer=prompt("What is the best programming language?");
if (answer.toUpperCase()==="JAVASCRIPT")
{
alert("You are correct");
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
3 Answers
Christopher Parke
21,978 PointsIt's because you're using strictly equals (===) rather than evaluates to (==). You don't want to be checking variable type as well. You want it to try to convert the type.
Lee Fendley
6,689 PointsHi Prabhuram,
Firstly the code you have typed is correct, however it's not what the evaluator is expecting. Charalampos is correct in stating you do not need to covert the answer to uppercase. Whilst this would be a better practise to avoid case sensitivity issues for the purpose of this task you only need that the answer variable be strictly compared to the string 'JavaScript'.
Doing this will pass the test :)
Thanks
Charalampos Anargyrou
14,031 PointsI am not sure why you are getting the error when comparing to "JAVASCRIPT" but if you drop the .toUpperCase() and compare the answer to "JavaScript" you should be ok.