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

Kevin Faust
Kevin Faust
15,353 Points

challenge 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
Jeff Lemay
14,268 Points

The 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'); 
}
Kevin Faust
Kevin Faust
15,353 Points

very 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
Jake Adams
1,608 Points

Kevin 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
Jeff Lemay
14,268 Points

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

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

Jake Adams
Jake Adams
1,608 Points

For 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

Jake Adams
Jake Adams
1,608 Points

see my updated answer