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

My challenge answer appears to be correct, but I get an error saying that the earlier task answer is no longer passing.

On Task 2, I get the error "Oops! It looks like Task 1 is no longer passing". I see nothing wrong with my Task 1 answer, and it passes when I go back to it. But, when I add the conditional statement for Task 2, I get that same error about Task 1. The dialog boxes for the prompt (Task 1) and the alert that is a result of the conditional processing (Task 2) are working.

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

It looks like you're being too smart for the task. The question is asking you to check wether the variable answer contains the string 'JavaScript' pay attention to the capitalisation. It's not asking if answer contains the string 'JAVASCRIPT' simplify your code to this and you should pass.

if (answer === 'JavaScript') {
  alert goes here
}

Thank you, Pete! That worked for me! The answer wasn't looking for me to convert to uppercase.

I'm new to Treehouse, and I love it! The videos are excellent, and the forum is great. I really appreciate your quick response.