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

Lennie Polanco
Lennie Polanco
14,415 Points

javascipt conditional number 1

my conditional isnt working

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

if(answer === '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>

5 Answers

If src="app.js" on your script tag is the correct file path then it all looks right. Are you typing "Javascript" into the prompt correctly (all the proper capitalizations) ?

Try typing answer === "JavaScript" in your if statement.

Lennie Polanco
Lennie Polanco
14,415 Points

Yes I am. Correct file and I typed Javascript into the prompt and the conditional worked. I don't understand why it isn't letting me pass....so odd.

Lennie Polanco
Lennie Polanco
14,415 Points

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

alert("You are correct");

};

This did not work. frustrating...a bug?

if(answer === "Javascript") is where you are incorrect. It needs to be if(answer === "JavaScript"). The capital S is important.

Lennie Polanco
Lennie Polanco
14,415 Points

wooooooowww!! something so small...sheesh! You an tell i'm a noob.

Thank you Erik! I greatly appreciate your time and help!

Man, you have tons of points! I hope to be like you one day!

Ha, no problem!

Keep at it and you will also be swimming in Treehouse points in no time :P

Lennie Polanco
Lennie Polanco
14,415 Points

haha Thanks! I just messaged you on your site btw. I would like to pick your brain a bit if you don't mind.

You're site is awesome btw and cool minesweeper! def a classic!

Lennie, I got your messaging!

I will respond to you this evening, but first I have to go get some pizza or I will faint :P

Lennie Polanco
Lennie Polanco
14,415 Points

Haha awesome! Buffalo Chicken bro! Can't go wrong...

Thank you.