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

Ammon D'Addabbo
Ammon D'Addabbo
7,866 Points

My Conditional Quiz!

This was my solution.

var score = 0;
var q1 = prompt('Who lived with the 7 dwarves?'); // Snow White
if (q1.toUpperCase() === 'SNOW WHITE') {
  score += 1;
  alert('That is correct! Your score is ' + score);
} else {
  alert('That is incorrect. Your score is ' + score);
}
var q2 = prompt('Name one of those 7 dwarves.'); // Doc, Dopey, Happy, Sleepy, Sneezy, Bashful, and Grumpy.
if (q2.toUpperCase() === 'DOC' || q2.toUpperCase() === 'DOPEY' || q2.toUpperCase() === 'HAPPY' || q2.toUpperCase() === 'SLEEPY' || q2.toUpperCase() === 'SNEEZY' || q2.toUpperCase() === 'BASHFUL' || q2.toUpperCase() === 'GRUMPY') {
  score += 1;
  alert('That is correct! Your score is ' + score);
} else {
  alert('That is inccorect. Your score is ' + score); 
}
var q3 = prompt('What was the dwarves day job?'); // Mining
if (q3.toUpperCase() === 'MINING' || q3.toUpperCase() === 'MINERS') {
  score += 1;
  alert('That is correct! Your score is ' + score);
} else {
  alert('That is inccorect. Your score is ' + score); 
}
var q4 = prompt('Who poisoned Snow White?'); // The Queen
if (q4.toUpperCase() === 'THE QUEEN' || q4.toUpperCase() === 'QUEEN' || q4.toUpperCase() === 'HER STEPMOTHER' || q4.toUpperCase() === 'HER STEPMOM' || q4.toUpperCase() === 'STEPMOTHER' || q4.toUpperCase() === 'STEPMOM') {
  score += 1;
  alert('That is correct! Your score is ' + score);
} else {
  alert('That is inccorect. Your score is ' + score); 
}
var q5 = prompt('How was Snow White awakened?'); // With a kiss
if (q5.toUpperCase() === 'WITH A KISS' || q5.toUpperCase() === 'KISS' || q5.toUpperCase() === 'KISSED' || q5.toUpperCase() === 'THE PRINCE' || q5.toUpperCase() === 'PRINCE' || q5.toUpperCase() === 'PRINCE KISSED HER' || q5.toUpperCase() === 'THE PRINCE KISSED HER') {
  score += 1;
  alert('That is correct! Your score is ' + score);
} else {
  alert('That is inccorect. Your score is ' + score); 
}
 if (score === 5) {
  document.write('<h2>You\'ve earned the Gold Crown!</h2><br><p>Your knowledge of Snow White is vast. You\'ve attained the perfect score of ' + score + '!</p>');
} else if (score === 3 || score === 4) {
  document.write('<h2>You\'ve earned the Silver Crown!</h2><br><p>Your knowledge of Snow White is greater than most. You\'ve attained the grand score of ' + score + '!</p>');
} else if (score === 1 || score === 2) {
  document.write('<h2>You\'ve earned the Bronze Crown!</h2><br><p>Your knowledge of Snow White is adequate.  You\'ve the meager score of ' + score + '! Your review of this classic is recomended.</p>');
} else if (score === 0) {
  document.write('<h2>You\'ve earned no crown!</h2><br><p>Your knowledge of Snow White is severely lacking, as you\'ve garnished the score of ' + score + '. You need to drop everything, and refamiliar yourself with this classic immediately!</p>');
}
Mohamed Ahmed
Mohamed Ahmed
6,517 Points

How can I Add my code inside the question like you do ?

Ammon D'Addabbo
Ammon D'Addabbo
7,866 Points

This link leads you to a discussion of posting code to the forum. This is how I learned.

https://teamtreehouse.com/forum/posting-code-to-the-forum

-Cheers!