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

Jeffrey Huang
Jeffrey Huang
5,914 Points

Task 1 no longer passing

How come it states task 1 is no longer passing when I try to submit task 2?

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>

1 Answer

Jacob Herrington
Jacob Herrington
15,835 Points

Hi Jeffery!

Actually, your code would work perfectly in a real life situation. The problem is that you have confused the challenge engine.

This code passes:

var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {   // This line is the one I changed! 
  alert('You are correct');      // I got rid of your call to the toUpperCase() function
} 

In the future, just be careful to try and follow the instructions EXACTLY or you might confuse the challenge. It's a good idea to save your code locally or use Workspaces to build out ideas that don't fulfill the challenges because there are cases like this one where exploring past what the challenge expects of you is a good thing.

Jeffrey Huang
Jeffrey Huang
5,914 Points

Okay it works now, thank you!