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

Stu Bamforth
Stu Bamforth
3,393 Points

Step 1 is now not working

Hi

I'm pretty sure this should we working? Been trying to get past this step for awhile now and every time I add the if statement the first step stops working.

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>

4 Answers

Billy Bellchambers
Billy Bellchambers
21,689 Points

You are very close with this answer.

2 issues.

The question asks you to check if the answer is JavaScript so no upper case conversion is necessary, even though this is generally good practise so your answers are not case sensitive in this question its not required.

Also .toUpperCase() needs a set of brackets at the end if you are going to use this function this question does not require it.

The correct code for first 2 parts is as follows.

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

Hope that helps.

Happy coding.

Andrew Shook
Andrew Shook
31,709 Points

Try:

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

if(answer === "JavaScript"){
  alert("You are correct");
}
Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Stu,

Challenges are very picky and very specific. Task 2 asks you to compare the answer to "JavaScript" with a capital J and a capital S. Your code is more/less correct, it is just not what the challenge asked for.

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

Once you change the conditional to match the challenge, you'll be good to go!

:dizzy:

Stu Bamforth
Stu Bamforth
3,393 Points

Thanks for help peeps!

Got it working now, I should have re-watched the video really!