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 Basic course - problem with one of the code challenges

Hi

I'm having a problem with one of the code challenges on the Javascript Basics course, specifically question 2 of this challenge Making Decisions with Conditional Statements

https://teamtreehouse.com/library/javascript-basics/making-decisions-with-conditional-statements/introducing-conditional-statements-2

Task 1 asks

"Add a variable named answer and use the prompt() method to ask the question 'What is the best programming language?'"

I wrote the code

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

Which works and I get the normal "Well done you're doing great" message

Task 2 asks

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

I wrote the code

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

I get the prompt which allows me to type "javascript", and an alert message saying "You are correct"

But I get an error message (and so can't progress to Task 3) saying

"Oops! It looks like Task 1 is no longer passing."

Which is kind of weird, because I haven't changed any of the code I wrote for Task 1.

I'm probably doing something wrong which is incredibly silly / basic, but any thoughts would be much appreciated.

thank you

3 Answers

In the challenge you are not supposed to use .toUpperCase() because the challenge what the statement to be true when the answer is "JavaScript" and not "JAVASCRIPT" or "javascript".

I hope this helps you in any way :)

Hi Henrik

Thank you, you're absolutely right.

Hugo

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