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

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?