Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Greg Schudel
Greg Schudel
4,090 Points

(JS Basics Course: Stuck on Conditionals) Looks like Task 1 is no longer passing

I'm struggling to get pas this quiz. It's very aggravating. The first part I type in is right:

var answer;

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

but when I type in the second part of the quiz's question to answer it, it always tells me that 'Looks like Task 1 is no longer passing' I have no idea what to place in there to get it correct. I'm simply being requested to use a if conditional statement to create a alert dialog box with the statement 'you are correct'. What am I missing? I feel stupid, because I bet this is beyond simple!!

var answer;

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

if (answer.toLowerCase === 'javascript') {

  alert('You are correct.');

}
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>

2 Answers

jacksonpranica
jacksonpranica
17,610 Points

Hey Greg!

Unfortunately, the awkward wording in the question is making this a bit more complicated then it should be. Especially since task one can pass without setting it up "properly".

So for the most part Greg you are on the right track! Here's just a few changes you have to make.

1) You need to store the response from the prompt in the answer variable. Right now the prompt isn't being stored so you are doing an if statement on answer with absolutely nothing there. Answer has no value.

2) Make sure to be careful with the .toLowerCase method. It needs to have a parenthesis on the end of it, i.e. toLowerCase(). This is because .toLowerCase() is a function, while .toLowerCase acts as a property on something. A little more complex wording there, but you will find out more about properties and functions as the lessons progress

Below is the answer. ------ Answer -----

var answer;

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


if (answer.toLowerCase() === 'javascript') {

  alert('You are correct.');

}
Greg Schudel
Greg Schudel
4,090 Points

Hmmm.. I had that in another example but instead I used uppercase to make the entry more accommodating. Not sure why that didn't work.

var answer;

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


if (answer.toUpperCase() === 'JAVASCRIPT') {

  alert('You are correct.');

}

Thanks for the encouragement. This is my second time doing a quick review on this section. I moved on to loops, arrays and objects and found myself lost in the challenges. Hoping this review helps. Thanks again.