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 trialScott Rigby
Full Stack JavaScript Techdegree Student 850 PointsKeep 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>"); }
Tim Sexton
14,882 PointsI 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().
Alexander Davison
65,469 PointsNo 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
2 Answers
Tommy Leng
Front End Web Development Techdegree Student 12,417 PointsYou have to write the exact code. You can't make it to uppercase just type in ' if(answer === 'JavaScript') {You are correct}'
Alexander Davison
65,469 PointsWrong. 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.
Tommy Leng
Front End Web Development Techdegree Student 12,417 PointsIt wouldn't change the answer to "JaVaScRiPt" since the answer would be the string 'JavaScript' so I have no idea what you are talking about and I wrote you shouldn't make it uppercase [i.e 'answer.toUpperCase()']. https://teamtreehouse.com/library/javascript-basics/making-decisions-with-conditional-statements/introducing-conditional-statements-2
Alexander Davison
65,469 PointsIt 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
20,364 PointsGuys: 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.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsWhat's the second task's question?