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

hello, I have no idea why it says task one is no longer passing because in my opinion it definitely should!

can someone help me with finding my mistake?

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

andren
andren
28,520 Points

There are two issues with your code:

  1. You don't actually call the toUpperCase function, you only reference it. In order to call functions you have to place parenthesis after the name of the function like this "answer.toUpperCase()"

  2. The return keyword is used to return data from a function, an if statement is not a function so using that is invalid. This is the reason why task 1 is no longer passing, this invalid syntax crashes the code checker as it tries to validate your code.

If you fix those two issues like this:

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

Then you'll be able to pass onto task 3.