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

Deborah Williamson
Deborah Williamson
2,997 Points

Error Message

I've noticed since I've started JavaScript that most times when I'm doing a code challenge I get a message saying "Oops! Its looks like Task 1 is no longer passing". This happens whether i get the answer wrong or right. Is anyone else experiencing this? Can anyone help?

app.js
var answer = prompt('What is the best programming language?')
if(answer === JavaScript){
document.write("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

Erik McClintock
Erik McClintock
45,783 Points

Deborah,

These challenges are built to look for a specific bit of code when you submit an answer, and while the errors are not always helpful (as is the case here), just interpret it at something in your code is not following the instruction of the task at hand. In this case, you have two errors in your code for task 2:

1) As Szilard mentioned above, you need to put your string JavaScript inside quotes to show that it is indeed a string

2) You are currently writing out the result of "You are correct" to the document, when the challenge is asking you to create an alert box with that message instead

Thus, your code should look like this to pass task 2:

var answer = prompt('What is the best programming language?'); // end this line with a semi-colon
// notice how "JavaScript" is inside quotes
if(answer === "JavaScript"){
    // notice how this is an alert(), rather than document.write()
    alert("You are correct"); // end this line with a semi-colon
}

Additionally, although it isn't causing the challenge to err out, you need to end your lines of code with a semi-colon. Notice above in my code block how line 1 and line 3 are ended with semi-colons.

Hope this helps!

Erik

Szilรกrd Koszta
Szilรกrd Koszta
6,904 Points

Try this: if(answer === 'JavaScript'){.....