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

I think this is right, can't see why the first task no longer works

thanks!

app.js
var answer = prompt("what is the best programming language?");
if (answer.toUpperCase === JAVASCRIPT) {
  document.write("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>

5 Answers

You have a couple of small mistakes

var answer = prompt("what is the best programming language?");
//Put your string in quotes. Use parenthesis with your method
//if (answer.toUpperCase === JAVASCRIPT) {
if (answer.toUpperCase() === "JAVASCRIPT") {
  //add semicolon
  //document.write("You are correct")
  document.write("You are correct");
}

ah! i see thank you

Ok, tried that and got ... There was an error with your code: TypeError: 'null' is not an object (evaluating 'answer.toUpperCase')

var answer = prompt("what is the best programming language?") if (answer.toUpperCase() === "JAVASCRIPT") { document.write("you are correct"); }

paste your code here

var answer = prompt("what is the best programming language?") if (answer.toUpperCase() === "JAVASCRIPT") { document.write("you are correct"); }

The only thing wrong with that is that you are missing a semicolon after the parenthesis and before the if

...programming language?"); if (ans...

I added the ; and it still said answer.toUpperCase was null....so strange thank you for you help!

Try this code as it's listed below and let me know if it works

var answer = prompt("what is the best programming language?");
if (answer.toUpperCase() === "JAVASCRIPT") {
  document.write("You are correct");
}
<!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>