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

laksh khamesra
laksh khamesra
4,475 Points

Objective won't go to next question even though answer is correct?

http://goo.gl/h5M1QP

Please see this screenshot. This is regarding: Javascript basics -> Making Decisions with Conditional Statements -> Introducing Conditional Statements

Even after I enter the correct answer in the prompt box, the test wouldn't pass it.

4 Answers

Samuel Key
Samuel Key
3,310 Points

What you enter into the prompt box comes back as a string, so you need quotes around JavaScript on line two. Also you don't need the paragraph tag in an alert box.

Try this:

var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
  alert('You are correct!');
}
Samuel Key
Samuel Key
3,310 Points

You can also add

var answer = prompt('What is the best programming language?');
if (answer.toLowerCase() === 'javascript') {
  alert('You are correct!');
}

so that capitalization doesn't matter.

Micah Fay
Micah Fay
11,780 Points

For some reason this challenge doesn't seem to accept .toLowerCase() or .toUpperCase() answers even if written correctly. I get the same looks like Task 1 is no longer passing. However if you just remove the method and capitalize the "JavaScript" string in your conditional it should run fine.

I also overlooked the capital S in JavaScript initially...

Jeff Chabot
Jeff Chabot
5,727 Points

Learntree can you please clarify this question? The step after adding the variable does not specify using toUpperCase or toLowerCase.

And, I've tried several questions and cannot get past this step. I keep getting the error

Oops! It looks like Task 1 is no longer passing.

toLowerCase and toUpperCase Didn't work for me either. My solution was using || if(answer=== 'ruby' || answer === 'Ruby' || answer ==='RUBY')