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 trialparvez ahsen ye
Courses Plus Student 2,086 Pointsit keeps on showing task no 1 is no longer passing
i have passed the challenge 1 but whats problem with my code
var answer;
answer = prompt("What is best programing 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>
2 Answers
Saleh Ben Nakhi
7,305 PointsI can see in your code that you've written the conditional statement as follows
if(answer==JavaScript)
Javascript is written as of its a variable, which you have not declared. If you want to compare you answer (which is a string stored within a variable) to a string, you should put Javascript within quotation marks.
if (answer == "JavaScript") should solve your problem.
Enjoy learning!
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsYou did forget to put JavaScript in a string, also remember that it is case sensitive, so typing in javascript instead of JavaScript in the prompt will ruslt in not passing.
This code should do it.
var answer = prompt("whts your favorit language?").toLowerCase();
if(answer== "javascript"){
alert("you are correct");
}