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

sami thakur
sami thakur
970 Points

i was doing the 2nd task of this challenge, and everytime i did it, it said the first task isnt working, please help

the title is pretty much the whole question

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>

2 Answers

Hi there,

You have the right idea - to make the code work in general, you just need some quotes, single or double, around JAVASCRIPT, since it's a string. I noticed the challenge still fails if you do that, though. What you've done here, converting to uppercase, is a good practice in an actual program (and what they do in the videos if I remember correctly), because it's more flexible for the user. However, this challenge asks specifically for you to compare to the string 'JavaScript', which means it's going to be picky here - you need to remove the .toUpperCase and make the string you compare to 'JavaScript' exactly - then it should pass.

Again, what you did with the uppercase conversion is generally something you want to do in your programs - the challenge is just asking for something specific :)

Final code should look something like:

var answer = prompt("What is the best programming language?");
if (answer === 'JavaScript'){
  alert("You are Correct");
}