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

Tornike Bestavashvili
Tornike Bestavashvili
4,275 Points

Task 1 in not passed

Hi, my code is working, but there's error, "it looks like Task 1 is no passing"... What i can do?

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

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Remember, even though you're currently at part 2 of the code challenge, each time you press the Check Work button, the grader will also evaluate your code against all previous parts of the challenge, should the grader check failed, you'll receive the it looks like Task 1 is no passing, or sth similar. That's why it's important to avoid unnecessarily modifying, directly or indirectly, the code written in the earlier parts of the challenge.

And the reason for this error message here is because, in the line 2 of your code, answer.toUpperCase() altered the value of answer variable, which caused Task 1 to fail.

To correct this, you should write your code without using the .toUpperCase().

var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript'){
  alert("You are correct");
}

Like this, hope it helps.

Tornike Bestavashvili
Tornike Bestavashvili
4,275 Points

It's helped, thank you William Li ;)