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

Christopher Denny
Christopher Denny
10,460 Points

Challenge task 2

In challenge task to, I complete the entire if-else statement including .toUpperCase My code works flawlessly and when I run it through JSHint, it comes up with no errors. When I submit it though, it comes up with "It looks like Task 1 is no longer passing." Here is my code:

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

if (answer.toUpperCase() === "Javascript".toUpperCase()) { alert("You are correct"); } else { alert("You are so wrong!"); }

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

if (answer.toUpperCase() === "Javascript".toUpperCase()) {
    alert("You are correct");
}
else {
  alert("You are so wrong!");
}
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

When using the .toUpperCase method to need to have the string also be upper case, so for this challenge you need to have the word "JAVASCRIPT" in all caps because the answer will be transformed into all caps. That's all you need to do. I hope this helps.

Christopher Denny
Christopher Denny
10,460 Points

Are you referring to the "Javascript".toUpperCase()

Like I've said, the code is working, however, my answer is not being accepted, so I'm not sure what part it's rejecting.

I'm going through the challenge right now and its giving some problems. I'm going to work on this for a bit, and Ill let you know what going on,

Okay, so a couple of things... one in order to pass this challenge you need to do what the tasks states and nothing more. So in this case you need to remove the .toUpperCase method, and you need to change the else alert string to what the challenge wants you to say. I also don't think you can use the toUpperCase like that on a string. but after that you should be good to go. Just follow the instructions to the T.

Christopher Denny
Christopher Denny
10,460 Points

Awesome, thanks a bunch again, Jacob!

Not a problem, Any time! Happy coding!