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

I get "Oops! It looks like Task 1 is no longer passing." message even though my code works

Re: The exercise with "What is the best programming language" and the answer should be "JavaScript." My code works when I test it in Chrome. I get the prompt asking the question and, if I type in 'JavaScript' I get the alert dialogue box telling me it is correct. However, I get the "no longer passing" message. What gives?

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

A new wrinkle, this time I get the error message "Bummer! There was an error with your code: TypeError: 'null' is not an object (evaluating 'answer.toUpperCase')"

When I test my code using the console, I get that message only if I hit 'cancel' on the prompt box. I then added an else statement with message 'You are wrong'. After that, the null message no longer appeared in the console box. However, when I submit it for the quiz, it keeps getting rejected.

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,863 Points

Hey Allen,

It's best if you ask questions right from the Challenge, as this will link your question to the exact place/quiz/challenge you are at by clicking on "Get Help."

However, I do recall where you are by the code. The problem you are encountering is because the challenges are VERY specific and VERY picky. I don't remember the exact wording of the question, but I do remember that it doesn't ask you to use toUpperCase() and that it wants you to compare "JavaScript" (with that exact case... Capital J and Capital S."

So, if you change you code to reflect that, you will be good to go.

if (answer == "JavaScript")

Keep Coding! :)

Jason:

Yes, that was it! I had a feeling it was a small thing like that. My original code for the answer worked and it debugged just fine. Sometimes it is hard to parse the exact answer they are seeking. They might have phrased the question something like, "Add a conditional statement that opens an alert dialog box with the message 'You are correct' where the ONLY correct answer is when the string is typed exactly as 'JavaScript'."

Many thanks for the prompt help.

I'm having trouble on task 2 of this question. Please help.