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 trialSupratim Nandi
3,287 PointsGlitch in the first Challenge
Prompt is returning null value while the preview is showing an expected value.
4 Answers
Colin Key
15,290 PointsThe .toUpperCase() method is attempting to be called on the answer variable but needs the parenthesis to be called. Like this
var answer = prompt("What is the best programming language?");
if (answer.toUpperCase() === 'JAVASCRIPT') {
alert('You are correct!');
}
Read more about .toUpperCase() on the Mozilla Developer Network
Supratim Nandi
3,287 PointsThat is the same code I have written Above...What is the difference in both! The checker is saying cant return the answer from task one!
Colin Key
15,290 PointsI went into the first code challenge itself to test this out and I was able to recreate your problem. The code challenge won't pass when adding the .toUpperCase() method as the question isn't asking for that. I was able to pass the code challenge without adding the .toUpperCase() method and using the same capitalization in the condition as the question states.
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert('You are correct');
}
So, while you code appears to be written with the correct syntax, you're going above and beyond what the question is asking and the code challenge won't pass that way. Hope this helps!
Supratim Nandi
3,287 PointsThe code is as follows:
var answer=prompt("What is the best programming language");
if(answer.toUpperCase==="JAVASCRIPT") { alert("You are correct!");
}
//the preview is right ..but the cheker is showing error!thtat answer has null value in it!
Supratim Nandi
3,287 Pointssorry I dint write the parenthesis here earlier!but I did the same dude in my actual programQ!still Error..please help meout!team treehouse isnt responding!
Robert Hernandez
9,357 PointsI tried to get it to pass (with your code and mine, several variations) and also ran across the same problem. Either it's a glitch, or I'm out of practice with JavaScript. Sorry I couldn't help.
Robert Hernandez
9,357 PointsRobert Hernandez
9,357 PointsIf you are still having a problem with this, please share your code. Thanks!