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

What is wrong with this code?

What is wrong with this code that wont allow the answer to be blue?

function colorGuess() {
    var question = prompt('What is your favorite color?');
        if (question.toUpperCase === 'BLUE') {
            alert('That is my favorite color');
        } else {
            alert('That is a nice color, but my favorite is blue!');
        }
}
colorGuess();

2 Answers

toUpperCase is a method of String prototype not property. Doing something like 'a'.toUpperCase will return identifier of function. You can fix this by calling the function with '()'.

So question.toUpperCase -> question.toUpperCase()

Thank you Gunhoo,

Simple mistake!

All the best, Dino

Let me know if things still don't work or you need more understanding.