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

Ezequiel Gonzalez
Ezequiel Gonzalez
1,358 Points

Cannot pass Task two but the code is OK

Task 1 passed ok, then arriving Task 2, I just added the conditional and alert when that one is true... I already tested this code on Chrome, even when the work is being checked the prompt appears and I fill the data and the logic occurs as described.

It is marked as wrong answer but with the following statement: Oops! It looks like Task 1 is no longer passing.

app.js
var answer = prompt('What is the best programming language?');
if(answer.toLowerCase() === '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>

3 Answers

Jeff Wilton
Jeff Wilton
16,646 Points

I agree that your code works, and is probably better than what they asked for, but they are only asking to check if the answer equals 'JavaScript'. So, omitting your .toLowerCase will satisfy the requirements.

var answer = prompt('What is the best programming language?');

if(answer === 'JavaScript'){
  alert("you are correct")
}
Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Ezequiel.

I think the problem is that the code challenge does not ask you to check against the lower version of the string. the check should simply be if answer equals to 'JavaScript'.

Vitto

Ezequiel Gonzalez
Ezequiel Gonzalez
1,358 Points

I thought I did in such way as well, but I tried your suggestions and now passed. Many thanks