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

something is wrong.

in his simple example , he uses brackets. isn't a string in javascript in <>? this should work?

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

10 Answers

Sorry, it should be

If(x===y){result}

I’ve been pretty acclimated to Python for the last eternity

Put the answer in “”?

I tried that ryan but it's still sticking.

Have you tried it in your code editor? What errror does it give you?

Oh.

What I would recommend would be removing the <>. Also, maybe wrap str() around the prompt, and also append answer.lower() === “javascript”

I haven’t coded in JS for a while- so append my code to work for the JS syntax

this is exactly how the instructor said to do this in his example of a simple conditional quiz. but it is not working. im confused

Oh! The entire condition has to be in parenthesis I think?

If (x=y){ result }

i'll try anything right now ryan. thanks

Hello Kim, Good attempt but there a few things you need to change for that to work. First, enclose strings in quotation (" ") marks. Also, document.write is a function. What I mean is that it needs to be called like document.write("write something"); According to the question in the practice exercise you're doing here, you'll not need to use document.write();, an alert is what is required. Your code refactored would be something close to:

var answer = prompt("What is the best programming language?");
if (answer.toLowerCase() === "javascript") {
  alert("You are correct!");
} else {
  alert("JavaScript is the best language.");
}

Cheers! Keep on hacking it!

Thank you. I'm drawing a complete blank on this for some reason. I'm trying to finish it but my brain is locked up