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

Seeing console error for line 4

I'm trying to follow along with the random number generator but I can't see what the issue could be here

var randomNumber = Math.floor(Math.random() * 6 ) + 1;
var guess = prompt('I am thinking of a number between 1 and 6. What is it?');
if (parseInt(guess) === randomNumber) {
  document.write('<p>That's right!</p>');
 } else {
  document.write('<p>Afraid not! The number was ' + randomNumber + '</p>');
}

2 Answers

put " " in the line 4:

document.write("<p>That's right!</p>");

I overlooked that I was using the single quotation mark within the string. Thanks very much!

Yes as said above the issue is with you using ' ' instead of " ". The only difference is demonstrated in the following:

'A string that\'s single quoted'

"A string that's double quoted"

So, it's only down to how much quote escaping you want to do. Obviously the same applies to double quotes in double quoted strings.