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

fatih tas
fatih tas
13,181 Points

at 2nd question on test, it does not accept true answer, claiming that my answer to 1st Q. is wrong. It is true.

So this is my answer to 1st: var answer = prompt ("What is the best programming language?");

and my answer to 2nd: var answer = prompt ("What is the best programming language?"); var cevap = answer.toLowerCase (); if (cevap === "javascript" ) { alert ("You are correct"); }

Yet i get an error message claiming i deleted or harmed my answer to 1st Q.

3 Answers

Damien Watson
Damien Watson
27,419 Points

Hi,

The challenge doesn't ask you to convert to lowercase and it is looking for "JavaScript" case sensitive. To pass the challenges you should only do what asked as thats what the challenge is looking for.

// 1st question
var answer = prompt ("What is the best programming language?");

// 2nd question
if (answer==="JavaScript") {
  alert("You are correct"); 
}

// I'll leave the third for you.
Chris Harkin
Chris Harkin
1,104 Points

Hay how do you add a screen shot of your code

fatih tas
fatih tas
13,181 Points

Hi Damien, i have tried that.. i actually tried like 5 different versions of working code.
did not work.

problem is: it thinks that, i have altered the 1st questions answer..

Thanks for looking up. -fatih

UPDATE: i copied your version and it worked.. Thanks SO MUCH

Damien Watson
Damien Watson
27,419 Points

Glad it worked for you. Enjoy the course.

Ionut Ghita
Ionut Ghita
1,951 Points

I'm having the same problem as Fatih. At question 2 in the test, when I enter the below script, I get " Bummer! Comparing strings is case sensitive. So 'Javascript' or 'javascript' is not equal to 'JavaScript'".

var answer = prompt("What is the best programming language?"); if ( answer === "Javascript") { alert("You are correct"); }

Now, when I add "toUpperCase()" after "answer", in the conditional statement. I get "Oops! It looks like Task 1 is no longer passing.".

var answer = prompt("What is the best programming language?"); if ( answer.toUpperCase() === "Javascript") { alert("You are correct"); }

But if I copy and paste the above code given by Damien, everything works.

// 1st question var answer = prompt ("What is the best programming language?");

// 2nd question if (answer==="JavaScript") { alert("You are correct"); }

// I'll leave the third for you.

What gives???

Damien Watson
Damien Watson
27,419 Points

Hi Ionut,

In your example you have the below which is not passing, this is because the challenge is looking for "JavaScript" with a capital 'J' and capital 'S'.

// Note: incorrect example
var answer = prompt("What is the best programming language?");
if ( answer === "Javascript") {
  alert("You are correct");
}

Your next bit of code fails as well mainly because they haven't said to use 'toUpperCase'. But if you were going to use convert to uppercase, then your check string would need to be in uppercase. This would look like:

// Note: incorrect example (this is valid script but will not pass the challenge)
var answer = prompt("What is the best programming language?");
if ( answer === "JAVASCRIPT") {
  alert("You are correct");
}