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


Conditional Statement Code Challenge

Within the Making Decisions with Conditional Statements section of JavaScript Basics, the Introducing Conditional Statements task part 2 of 3 keeps failing as it says part 1 of 3 fails when I run part 2.

My answer to part 1 which passes: var answer = prompt("What is the best programming language?");

My answer to part 2 which fails as I'm told part 1 has failed:

var answer = prompt("What is the best programming language?"); if (answer.toUpperCase() === "JAVASCRIPT") { alert("You are correct."); }


I've tried running the above task part 2 code in the Chrome console and it works so grateful for any thoughts as to what the issue may be.

I've re-run the code with "answer.toUpperCase()" replaced with "answer" and it works however, I'm unclear as to why it's not working with the toUpperCase() method?

3 Answers

Hi, rnas21:

It seems you are correct, it does seems you've found a flaw with the current tests associated with this challenge. I'll mention Dave McFarland about this along with contacting

Thanks for being investigative enough to explore this way of solving the challenge for this bug to be found so that other students don't encounter it in the near future that may lead to unnecessary frustration to complete this particular stage of the course.

David ODonovan
David ODonovan
Courses Plus Student 2,970 Points

bump! I am having the exact same problem so this section of the course has not been fixed: 'Making Decisions with Conditional Statements / Introducing Conditional Statements / Task 2'. My code runs fine in deve tools but not in the treehouse parser. Anyone have a solution? It would be great to pass this challenge so I can complete the course.. My code is as follows:

var answer = prompt('What is the best programming language?'); if (answer.toUpperCase() === "JAVASCRIPT"){ alert("You are correct"); }

David ODonovan
David ODonovan
Courses Plus Student 2,970 Points

The solution turned out to be annoyingly simple, but a good lesson; I had compared using the following; if(answer ==='Javascript')

The code was not passed because the word 'Javascript' has to be written in camelCase with a capital S like so: JavaScript.

I guess this lesson is about attention to detail...