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

Brittany Smith
Brittany Smith
8,046 Points

Task 1 passes but when I try Task 2 it tells me Task 1 is no longer passing?

When I try to check my work on Task 2 it tells me my Task 1 is no longer passing, but I go back to Task 1 and it passes. Sending me in an endless loop.

app.js
var answer = prompt("What is the best programming language?");

if ( answer === "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>

3 Answers

alert(You are Correct); should be: alert("You are Correct");

Brittany Smith
Brittany Smith
8,046 Points

Even if I correct that it still tells me that "Task 1 is no longer passing" sorry, I did correct that. I even tried erasing everything and retyping it in for task 2. idk what's going on.

var answer = prompt("What is the best programming language?");

if (answer === 'JavaScript') [
  alert("You are Correct!"); 
]

hmm thats weird, I tried your exact code, with the quotes in it of course and it passed without error...

var answer = prompt("What is the best programming language?");

if ( answer === "JavaScript") {
 alert("You are Correct"); 
}
Brittany Smith
Brittany Smith
8,046 Points

maybe it just wants double quotes instead of single quotes

No this shouldn't matter at all, as long as you close the string with the same number of quotes as you started. If the problem persists you should ask the question again and tag a moderator

Brittany Smith
Brittany Smith
8,046 Points

I was using square brackets instead of curly brackets

Well thats no good.