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 trialMichael Zeta
18,135 PointsStep two says Task 1 no longer passing even though it is identical to when it passed in step one.
Am I missing something or is this code challenge broken? Task 1 asks me to create a variable named 'answer' and to use the prompt() method to ask the user what is the best programming language. So I typed:
var answer; prompt('What is the best programming language?')
and this passes for step one. Then in step two I leave this code completely untouched but no matter what I do it always says that task one is no longer passing. Why? Please help.
var answer;
prompt('What is the best programming language?')
if (prompt === 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
Thomas Fildes
22,687 PointsHi Michael,
You need to check the answer variable in your if statement not the prompt. Prompt is just a method that asks for user input which we assign to a variable (answer). Here is the code I used to pass this part of the challenge:
var answer = prompt("What is the best programming language?");
if ( answer === "JavaScript" ) {
alert("You are correct");
}
Hope this helps! Happy Coding!!!