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

Caj Andersson
Caj Andersson
2,987 Points

Why doesn't my if statement work?

Can't figure out why my if statement doesn't work in this code challenge :(

Can anyone help?

app.js
var answer = prompt('What is the best programming language?')
if (answer === 'Javascript') {
  alert('You area 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>

1 Answer

Colin Marshall
Colin Marshall
32,861 Points

Make sure that strings in your answer are exactly how they are stated in the question. Capitalization matters. For example, Treehouse is not the same as treehouse.

Colin Marshall
Colin Marshall
32,861 Points

As a further hint, there are actually two things you need to change in your answer. One on line 2, and one on line 3.

Caj Andersson
Caj Andersson
2,987 Points

I found the issue with Java(S)cript. Thank you! Also corrected the spelling mistake on line 5 and it works great!