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

document.write not appearing on webpage

CODE BELOW

var question1 = prompt('What is the best color?');
if (question1.toUpperCase() === 'GOLD') { window.alert("That's Correct!"); } else { window.alert("Sorry, That's Incorrect!"); }

var question2 = prompt('How many shrimps do you have to eat before you make your skin turn pink?');
if (question2 === '30' || question2 === 'thirty') { window.alert("That's Correct!"); } else { window.alert("Sorry, That's Incorrect!"); }

var question3 = prompt('How many licks does it take to get to the tootsie roll center of a tootsie pop?');
if (question3 === '2,000' || question3.toUpperCase === 'TWO THOUSAND' ) { window.alert("That's Correct!"); } else { window.alert("Sorry, That's Incorrect!"); }

var question4 = prompt('Who wants to be the very best, like no one ever was?');
if (question4.toUpperCase() === 'I DO' || question4.toUpperCase() === 'ASH' ) { window.alert("That's Correct!"); } else { window.alert("That's Incorrect!"); }

var question5 = prompt('Im blue?');
if (question5.toUpperCase === 'IF I WERE GREEN I WOULD DIE' || question5.toUpperCase === "IF I WE'RE GREEN I WOULD DIE" || questions5 === '1' ) {window.alert("That's Correct!"); } else { window.alert("That's Incorrect!"); }

document.write('you finished the quiz');

Moderator edited: Added markdown so the code renders properly in the forums. Note that the spacing and formatting were left intact.


The prompt boxes show up fine and the correct answers generate the "That's correct" alert message but whenever I try using the "document.write();" function (to add writing to the page) nothing appears. This is killing me because I need to store the score values next as part of this assignment but I can't know if it's storing the values properly UNTIL I can guarantee that what I write in document.write(); WILL APPEAR. So is there something here that's keeping it from running?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You have a syntax error on the line immediately before the document.write which is preventing it from running.

You wrote:

|| questions5 === '1'

But questions5 is undefined. You meant to write:

|| question5 === '1'

//note the removal of the "s" between the "n" and "5"

Hope this helps! :sparkles:

Thank you so much!