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

Why would this not work as a solution to the challenge? It does exactly what the challenge asks for?

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

if ( answer === 'Javascript' ) { alert("You are correct"); }

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>

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Sawyer;

The challenge engine is looking to make sure you are checking that answer is equal to "JavaScript", not "Javascript".

Happy coding,

Ken

Becky Castle
Becky Castle
15,294 Points

Hi Sawyer,

Just to expound upon what Ken was saying, the program is super-picky about upper and lower-cases; whereas we would view "javascript" as the same word as "JavaScript", the program does not. To remedy this, you'll want to change the user's input to either all uppercase or lowercase. Then the program can compare that to the correct answer, which should be in either all uppercase or lowercase (depending on what you changed the user's input to earlier).

For example:

var answer = prompt("What is the best programming language?");
var answer2 = answer.toUpperCase();
if ( answer2 === 'JAVASCRIPT' ) {
  alert("You are correct");
}
Ken Alger
Ken Alger
Treehouse Teacher

Becky;

That is a great point for production code. For the challenge however, it is looking for "JavaScript", just for clarification for future readers of this post.

Ken

Becky Castle
Becky Castle
15,294 Points

Oh, ok. Thanks, Ken! I didn't realize that.

Becky

Sorry my attention to detail has been lacking today!

Becky Castle
Becky Castle
15,294 Points

It's always nice to have a second set of eyes ;-)