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

if conditional follows by alert not working

var answer = prompt('What is the best programming language?'); if ( answer toUpperCase === ('Ruby'){ alert('you are correct')}

it doesn't work

1 Answer

You didn't construct your conditional statement properly. You're missing:

a full-stop to apply the 'toUpperCase' method to the 'answer' variable,

you didn't call the 'toUpperCase' method with a parenthesis(toUpperCase()),

a closing parenthesis after the test condition and,

a semi-colon at the end of the alert method.

if ( answer.toUpperCase() === ('Ruby')){
   alert('you are correct');
}

As a bonus you don't need to wrap the string 'Ruby' in parenthesis, you can delete them.

Osaro, inserting, the quote above here if the Answer:Bummer! Compare with toUpperCase() === 'JAVASCRIPT'

I try to make up what's wrong , but I'm puzzle, THANK YOU

Oh yea, silly me I forgot. It should be 'RUBY' not 'Ruby'