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
Jessica Murillo
9,119 PointsOops! 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
Jacob Mishkin
23,118 PointsYou 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.
Russell Sawyer
Front End Web Development Techdegree Student 15,705 PointsJessica,
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.
Digvijay Jaiswal
5,565 PointsI believe that you copied over the task 1 code on to the task 2? Because your code is absolutely fine.
Jessica Murillo
9,119 PointsYes I did, it said to just add to the code from the first task.
Digvijay Jaiswal
5,565 PointsTry re-attempting it, that's all i can think of as of now.
Jessica Murillo
9,119 PointsThank 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.
Jacob Mishkin
23,118 PointsYou'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.
Jessica Murillo
9,119 PointsIt 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.
Jessica Murillo
9,119 PointsJessica Murillo
9,119 PointsOmg...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!
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsAwesome, Glad I could help.