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

Nothing shows up : previewing quiz.js shows nothing

My code: /* First, it has to ask at least five questions. Second, keep track of the number of questions the user answered correctly. Third, provide a final message after the quiz, letting the user know the number of questions he or she got right. And fourth, rank the player. If the player answered all five correctly, give that player the gold crown. Three to four is a silver crown. One to two correct answers is a bronze crown. And zero correct is no crown at all. */

// Question #1 : if answered correctly, score becomes 1 var answer1 = prompt("How many US Presidents have been assassinated while in office?"); if ( parseInt(answer1) === 4 ) { document.write("That is correct!"); var correctAnswers = 1; } else { document.write("Sorry - that's not correct."); } // Question #2 : if answered correctly, score becomes 2 var answer2 = prompt("Which US Great Lake is the largest?"); if ( answer2.toUpperCase() === 'LAKE SUPERIOR' || 'SUPERIOR' ) { document.write("That is correct!"); correctAnswers += 1; } else { document.write("Sorry - that's not correct."); } // Question #3 : if answered correctly, score becomes 3 var answer3 = prompt("In what year did the Civil War start?"); if (parseInt(answer3) === 1861 ) { do cument.write("That is correct!"); correctAnswers += 1; } else { document.write("Sorry - that's not correct."); } // Question #4 : if answered correctly, score becomes 4 var answer4 = prompt("Who is on the $20 bill?"); if ( answer4.toUpperCase() === 'ANDREW JACKSON' || 'JACKSON' ) { document.write("That is correct!"); correctAnswers += 1; } else { document.write("Sorry - that's not correct."); } // Question #5 : if answered correctly, score becomes 5 var answer5 = prompt("Who of the following is NOT depicted on Mt. Rushmore: George Washington, Thomas Jefferson, Abraham Lincoln, John Kennedy?"); if ( answer5.toUpperCase() === 'JOHN KENNEDY' || 'KENNEDY' ) { document.write("That is correct!"); correctAnswers += 1; } else { document.write("Sorry - that's not correct."); } // Depending on how many answered correctly, the messages below print if (correctAnswers === 5 ) { document.write("You got them all right! You win the gold crown!"); } else if (correctAnswers > 2 && correctAnswers < 5 ) { document.write("You won the silver crown! Nice job!"); } else if (correctAnswers > 0 && correctAnswers < 3 ) { document.write("You won the bronze crown! Well done!"); } else (correctAnswers < 1 ) { document.write("You didn't get any right. You might want to take a US History course! :) "); }

Found it - I had a space in "do cument" in Q3. Grrr ....

1 Answer

Steven Parker
Steven Parker
229,788 Points

Congratulations on resolving your issue! :+1:

For future questions, when sharing code please use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down: Or watch this video on code formatting.