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 trialmelissawright
5,903 PointsTask 1 no longer passing?
When I run the following code, it passes: var answer = prompt('What is the best programming language?');
but when I add the conditional statement, like this: var answer = prompt('What is the best programming language?'); if (answer.toUpperCase() ==='JAVASCRIPT') { alert("You are correct"); };
It says "Oops, Task 1 is no longer passing".
What am I doing wrong?
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>
2 Answers
Joseph Perez
25,122 PointsHi Melissa!
The challenge wants you to not use the javascript uppercase method. So your code should look like this :)
var answer = prompt('What is the best programming language?');
if(answer === 'JavaScript') {
alert('You are correct');
}
Leyton Parker
6,556 Pointsyou don't need the ; at the end of your if loop
melissawright
5,903 PointsThanks for the reply - I tried removing the semicolon, and the code runs correctly in the browser, resulting in an alert saying "You are correct", but I still get the error about Task 1.
Leyton Parker
6,556 Pointstry starting the code challenge over from the beginning, i've had a similar issue where the challenge would not accept the correct task 2 until it reconfirmed that task 1 was correct.
maybe that'll work
melissawright
5,903 Pointsmelissawright
5,903 PointsHi Joseph!
Thank you - I removed the semicolon on the if statement, as well as logged out and restarted the challenge, and it is still giving me the same error (in spite of the fact that I get "You are correct" in the browser).
Joseph Perez
25,122 PointsJoseph Perez
25,122 PointsI edited my original answer to better guide you. The challenge instructions can be a little tricky sometimes, I hope this helps :)
melissawright
5,903 Pointsmelissawright
5,903 PointsAwesome, problem solved! :)