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 The Conditional Challenge Solution

help

Can// quiz begins, no answers correct

code.js
var correct = 0;

// ask questions

var answer1 = prompt('Name a programming language that is also a gem');
  if (answer1.toUpperCase() === 'RUBY') {
    correct += 1;
  }

var answer2 = prompt('Name a programming language that is also a snake');
  if (answer2.toUpperCase() === 'PYTHON') {
    correct += 1;
  }

var answer3 = prompt('What language do you use to style web pages?');
  if (answer3.toUpperCase() === 'CSS') {
    correct += 1;
  }

var answer4 = prompt('What programming language do you use to build structure of web pages?');
  if (answer4.toUpperCase() === 'HTML') {
    correct += 1;
  }

var answer5 = prompt('What language do you use to add interactivity to a web page?');
  if (answer5.toUpperCase() === 'JAVASCRIPT') {
    correct += 1;
  }


// Output Results
  document.write("<p>You got " + correct + " out of 5 questions correct.</p>");

// Output Rank

  if (correct === 5 ) {
    document.write("<p>You earned a gold crown!</p>");
  } else if (correct >= 3 ) {
    document.write("<p>You earned a silver crown.</p>");
  } else if (correct >= 1 ) {
    document.write("<p>You earned a bronze crown.</p>");
  } else {
    document.write("<p>"No crown for you. You need to study."</p>");

I am having problems with this code not working. Also, when I try and access this group help forum, every time I push the space bar while I type in this comment section it re-starts my course video from the treehouse course I'm on. Is there a glitch or am I doing something wrong? Thanks.

Bryan

1 Answer

On your second to last line you have an extra set of quote marks around your document write statement. You also need to add a final } to end your else statement. It should look like:

else { 
document.write("No crown for you. You need to study.");
}