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 trialSawyer Bateman
Courses Plus Student 5,219 PointsWhy 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"); }
var answer = prompt("What is the best programming language?");
if ( answer === 'Javascript' ) {
alert("You are correct");
}
<!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
Treehouse TeacherSawyer;
The challenge engine is looking to make sure you are checking that answer
is equal to "JavaScript", not "Javascript".
Happy coding,
Ken
Becky Castle
15,294 PointsHi 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
Treehouse TeacherBecky;
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
15,294 PointsOh, ok. Thanks, Ken! I didn't realize that.
Becky
Sawyer Bateman
Courses Plus Student 5,219 PointsSorry my attention to detail has been lacking today!
Becky Castle
15,294 PointsIt's always nice to have a second set of eyes ;-)