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

Updated Completed Coded for Conditional Challenge Solution

I am testing the Teacher's Note Completed code which was provided. Is there a reason it is not working? https://w.trhou.se/xhil8hcuuo

// quiz begins, no answer correct
var correct = 0;

// ask questions
var answer1 = prompt ("Name a programming language that's also a gem");
if (answer1.toUpperCase() === 'RUBY') {
 correct += 1; 
}
var answer2 = prompt ("Name a programming language that's 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 language do you use to build th 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;
}

// ouput results
document.write("<p>You got " + correct + " out of 5 questions corret.</p>");

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

Can you post the code here? Also did you see the teacher's notes for the video?

Steven Parker
Steven Parker
231,236 Points

The best way to share code is to make a snapshot of your workspace and post the link to it here, it makes it easy to replicate the issue and examine it.

1 Answer

Steven Parker
Steven Parker
231,236 Points

It looks like you're missing a closing parenthesis after "What language do you use to style web pages?".

And for future questions, when pasting code in directly, always use Markdown formatting.

Sharp eye Steven! Thank you so much for the tip too!