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

parvez ahsen ye
PLUS
parvez ahsen ye
Courses Plus Student 2,086 Points

it keeps on showing task no 1 is no longer passing

i have passed the challenge 1 but whats problem with my code

app.js
var answer;
answer  = prompt("What is best programing 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>

2 Answers

Saleh Ben Nakhi
Saleh Ben Nakhi
7,305 Points

I 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!

You 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");

}