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

marci villa
marci villa
975 Points

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

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

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");
}
marci villa
marci villa
975 Points

ah! i see thank you

marci villa
marci villa
975 Points

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"); }

marci villa
marci villa
975 Points

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

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

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

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

marci villa
marci villa
975 Points

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

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

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>