Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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