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

Task 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?

app.js
var answer = prompt('What is the best programming language?');
if (answer.toUpperCase() ==='JAVASCRIPT') {
  alert("You are correct");
};
index.html
<!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
Joseph Perez
25,122 Points

Hi 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');
}

Hi 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
Joseph Perez
25,122 Points

I edited my original answer to better guide you. The challenge instructions can be a little tricky sometimes, I hope this helps :)

Awesome, problem solved! :)

you don't need the ; at the end of your if loop

Thanks 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.

try 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