Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Is the quiz broken? I add code that works in my workspace but I keep getting Task 1 is no longer passing

My code is

var answer = prompt('What is the best programming language?');
if ( answer.toUpperCase() === 'JAVASCRIPT' ) {
  document.write('That is correct');
} else {
  document.write('Sorry that\'s wrong');
}

3 Answers

Tobias Helmrich
Tobias Helmrich
31,602 Points

Alright. There are two problems in your code. Firstly you have to output the messages in an alert window instead of writing it to the document. The other problem is that you have to check for the exact string "JavaScript", with an uppercase "J" and an uppercase "S" in this challenge. Your solution is actually better because the user can type JavaScript in any way but the challenge wants to have the correct writing of JavaScript and nothing else.

Besides that also note that the strings should be like the challenge wants them to be ("You are correct" and "JavaScript is the best language!")

So this should do it:

var answer = prompt('What is the best programming language?');

if(answer === 'JavaScript') {
  alert('You are correct');
} else {
  alert('JavaScript is the best language!');
}

I hope that helps, if you have further questions feel free to ask! :)

OK got it, Really appreciated Tobias

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Don,

could you please post a link to the quiz where this is happening so I can go and have a look at it?