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

mohammed mayat
mohammed mayat
4,228 Points

task 1 not passing

how come when i try to do task 2, task 1 does not pass even though i hav not touch code for task 1 this has happen to me couple of times

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

if === ("javascript") {
  alert("<p>You are correct</p>")
}
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>

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The most common reason for this error with Task <number> is no longer passing is because of a syntax error, which is the case here. The code you've provided can no longer be interpreted.

In your case, there's a few things that are incorrect. The string you're comparing to must be exactly like the string they want it compared to which is "JavaScript". You're trying to compare it to "javascript". These strings are not identical. Although it is not causing an error, there is no reason to include the <p> tags in the alert.

Besides this, you've forgotten to say what you're trying to compare. What if your site had dozens of variables? Which one should it compare to "JavaScript"?

This is how I solved this step of the challenge:

var answer = prompt("What is the best programming language?");  //get an answer from the user and assign it to a variable

if(answer === "JavaScript") {  // compare answer to JavaScript
  alert("You are correct")  //alert the user if they typed JavaScript
}

Hope this helps! :sparkles: