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 trialKevin Faust
15,353 Pointschallenge task 2/3 js
var answer = prompt('What is the best programming language?');
if (answer.toUpperCase() === "JAVASCRIPT") {
alert("You are correct");
}
i keep getting an error
2 Answers
Jeff Lemay
14,268 PointsThe challenge didn't ask you to convert the answer to uppercase, you copied that from the lesson video. Be sure to follow the challenges carefully.
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert('You are correct');
}
Jake Adams
1,608 PointsFor task 1, all you need is the var answer = prompt("")
line.
I ran through all the tasks and none of them like the .toUpperCase()
as well, so you should remove that
Kevin Faust
15,353 Pointsi meant task 2
Jake Adams
1,608 Pointssee my updated answer
Kevin Faust
15,353 PointsKevin Faust
15,353 Pointsvery weird. that is what i did at first and it said "JavaScript" is not the same as "javascript" and that's why i used the upper() method but now its suddenly working :/
Jake Adams
1,608 PointsJake Adams
1,608 PointsKevin P JavaScript is case sensitive, so JavaScript is indeed no equal to javascript. In practice, we would use .toLower or .toUpper, but as Jeff said, it's not expected in this challenge.
Jeff Lemay
14,268 PointsJeff Lemay
14,268 PointsGood point to bring up, Jake. Thanks.
I think a couple good examples are usernames and promo codes. Just run them through toUpperCase/toLowerCase before you run your check. You wouldn't want to run a promo with the word "Treehouse" and require users to enter in that exact capitalize. TreeHouse, treehouse, TREEHOUSE, and TrEeHoUsE should all be treated the same.
Elisabeth Zak
3,793 PointsElisabeth Zak
3,793 Pointsedit - I didn't capitalize the S in JavaScript. Doh.
I have this: var answer = prompt('What is the best programming language?'); if (answer.toUpperCase() === 'JAVASCRIPT') { alert('You are correct'); } and it says task 1 is no longer passing. Did what you suggested and took out the toUpperCase, and get this message: Bummer! Comparing strings is case sensitive. So 'Javascript' or 'javascript' is not equal to 'JavaScript' So, I'm stuck.