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

Keep encountering 'Oops! It looks like Task 1 in no longer passing' Can't see any issues with my code?

var answer = prompt('What is the best programming language?'); if ( answer.toUpperCase() === 'JAVASCRIPT' ) { document.write("<p>You are correct</p>"); } else { document.write("<p>You are wrong</p>"); }

What's the second task's question?

Tim Sexton
Tim Sexton
14,882 Points

I don't know if you figured this out yet, but if you skip ahead in the second task and convert the answer to uppercase it doesn't seem to work. Also make sure you are using the correct method to post content to the page, the task asks you to use something other than document.write().

No what exactly does the task ask for?

Don't make up your own words please; copy and paste the task's question :)

That way I can really understand.

P.S.: Code Challenges don't currently work for me, so I can't go to the next task :smile:

2 Answers

Wrong. answer.toUpperCase() will turn "JavaScript" (if answer is JavaScript) into "JAVASCRIPT", and, if the answer was something weird like "JaVaScRiPt", when we .toUpperCase() it then it will still be "JAVASCRIPT" anyway.

It is considered better practice to .toUpperCase() or, more often, .toLowerCase() with inputs (the code challenge is basically giving input as the answer variable which could be any value that has a different case of "javascript", so it's better to just make it uppercase or lowercase).

nico dev
nico dev
20,364 Points

Guys: Alexander Davison and Tommy Leng

What happened here, about which Scott Rigby doesn't seem to care too much, by the way :) was just you misunderstood each other, but both are right.

I know this because I just went through this code challenge and had problems myself to solve it. :) That's why I came here.

What you said, Alexander, was completely true, in the sense that if you use toUpperCase with the variable answer, no matter what the user decides to type, if "javascript," "JavaScript," "JaVaScRIpt" or "JAVASCRIPT," just to name a few possible alternatives, the condition (for the if) will be met, and thus the answer will be correct. However, like you said, at least in that moment, you could not access to the code challenge; thus, you couldn't see why Tommy answered like that.

You, Tommy, were also right, since what the code challenge was requesting was that the string be "JavaScript" (please do notice my capitalization). I realized this because I clumsily typed Javascript in my first attempt, and it was rejected and explained why (no capital S in the middle of the word).

So while it is not necessarily the best way to do it in general, but for what's requested in this particular code challenge, the correct way to do it is like you said, not (yet) including the toupperCase in the equation, because that's not requested in this particular step of the cc.

I wanted to thank you, also, because for being so passionate and involved, you're helping others (like me) to learn better! :)

NOTE: Just for the record, Tim Sexton was also right. The code challenge is not asking for a document.write.