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 Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Supratim Nandi
Supratim Nandi
3,287 Points

Glitch in the first Challenge

Prompt is returning null value while the preview is showing an expected value.

Robert Hernandez
Robert Hernandez
9,357 Points

If you are still having a problem with this, please share your code. Thanks!

4 Answers

Colin Key
Colin Key
15,290 Points

The .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
Supratim Nandi
3,287 Points

That 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
Colin Key
15,290 Points

I 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
Supratim Nandi
3,287 Points

The 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
Supratim Nandi
3,287 Points

sorry 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
Robert Hernandez
9,357 Points

I 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.