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

John Caraballo
John Caraballo
19,943 Points

Task 2 is broken for the first challenge of the js conditionals section

I completed task 1 just fine but now when I head to task # 2 and add the needed code it says that task 1 is no longer passing and yet the prompt shows up perfectly and I am positive my added code is perfect as I tested it locally. My guess is something is going wrong on treehouse's end

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

// I also tried .toUpperCase here
if(answer.toLowerCase() === 'javascript') {
  alert("You are correct");
}
else{
//This was added to test if maybe I needed the else to pass but no go
}
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>

4 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey John,

Challenges are very specific in what they want and what will pass. The second part of the challenge asks to create a conditional to test if the answer is "JavaScript" (with a capital J and a capital S). It will accept NOTHING else.

So the code needed for task 2 is

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

if (answer === "JavaScript") {
  alert("You are correct");
}

Keep Coding! :)

John Caraballo
John Caraballo
19,943 Points

Oh haha I was just being defensive with my programming in case the tests used JAVASCRIPT or something like jAvAScript but all right. MY brain thought too much ahead haha thank you!

I am facing the same issue even after I tried using the code posted above.Need help

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hi Robert, Which Task are you on? The code I inserted above will pass Task 1 and Task 2 (I just double checked it). It will not pass Task 3 as you need to add the else statement.

Jason thx for the fast answer I already solved it.