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 trialLucas Huerta-Murillo Grau
Courses Plus Student 1,365 PointsWhat's wrong with my code?
The task is to 'Add a conditional statement that opens an alert dialog box with the message "You are correct" when the answer is the string 'JavaScript'.'
Here is the code I submitted.
var answer = prompt("What is the best programming language?");
if(answer.toUpperCase === "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>
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! While it's a great idea to turn the user's input to uppercase and then compare it to the all upper case version, this will not work for the challenge. They want the answer to be case-sensitive. So your condition should be altered to reflect this. Also, the toUpperCase
should be written as toUpperCase()
if used.
if(answer === "JavaScript")
On a side note, it's important to take these challenges very literally and try not to do anything the challenge doesn't explicitly ask for. Even if functional, it can cause the challenge to fail.
Hope this helps!