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

Jake Peyser
Jake Peyser
3,303 Points

Bug in Task 2

This module will not complete for me. I am 100% confident it works and even executes when I click "Check Work", however, when I complete Step 2 it tells me my Step 1 answer no longer works. There is a bug somewhere here that I am unable to get around.

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>

1 Answer

While your answer my work. It is not what the challenge is asking for.

Add a conditional statement that opens an alert dialog box with the message "You are correct" when the answer is the string 'JavaScript'.

The answer you are providing is converting the answer to lower case, which your answer would be correct, but because the challenge is not requesting a lowercase answer. It is not a passing answer. Try this.

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

if(answer === "JavaScript"){
  alert("You are correct");
}

I hope this helps.

Jake Peyser
Jake Peyser
3,303 Points

Thank you Chyno, that did work. I did try that first and it said I was incorrect because the code only worked for "exact input strings" or something like that, which led me to use the toLowerCase function. Not exactly sure what I did wrong that time, but it is possible I made another error that I did not catch although the "hint" was misleading.

Yeah. sometimes these code challenges can be a bit TOO specific in answers they want but if you ever have another problem, always feel free to post on the forums. I and the rest of the community would be more than happy to help.