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

Oops! It looks like Task 1 is no longer passing from Code Challenge task 2

Ok, so the first task asks to create a variable out of the response from the question 'What is the best programming language?' and I do like this:

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

This passed but then the second task asks me to create a conditional if statement to alert the user if correct and I do:

if ( answer.toUpperCase() === "JAVASCRIPT") {
     alert("You are correct");
}

As soon as I do that though it tells me that the first task is not passing anymore. I even just put

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

if(){}

To test it and it gives me that same error. What am I doing wrong? Can someone help me please?

6 Answers

You answer is correct in general programming, but the challenges make up check very certain things.

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

what you have in your conditional is .toUpperCase === "JAVASCRIPT"

The challenge wants you to not use .toUpperCase and to just use the string "JavaScript" with both the J and S caps. After that you should be good to go.

Omg...I am retarded lol. Thank you. I got confused when I got the error for what will happen if the user puts "Javascript" or "javascript" and assumed that's what I had to do. I need to read more thoroughly lol!

Awesome, Glad I could help.

Jessica,

The error messages, sometimes are just telling you that something is wrong and you haven't completed the challenge correctly. Just keep working on completing challenge 2. Once you complete it correctly it will pass.

I believe that you copied over the task 1 code on to the task 2? Because your code is absolutely fine.

Yes I did, it said to just add to the code from the first task.

Try re-attempting it, that's all i can think of as of now.

Thank you. I am trying different things but my code works just find in the browser. The alert pops up and everything. I went back to task one to see why it was not passing and it gives me this error now: Bummer! There was an error with your code: TypeError: 'null' is not an object (evaluating 'answer.toUpperCase') I thought my it was because I wasn't putting anything into the prompt but I did and I still gave me that error.

It is bothering me that I am missing a circle in Javascript Basics lol.

You're fine what you wrote is correct. Remember theses challenges are programmed just like having an alert button appear. You need to do exactly what the question asks you to do, if not it will return false, much like the conditional statement you are writing in this challenge.

for the first question, create the var iike before and then do not add the all caps or toUpperCase method, and it will pass.

It did work. Thank you again! I glad to have completed it. It was bothering me haha! Plus everyone was very quick to answer which was answer.