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!
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

Benjamin Miller
4,344 Pointshow the heck?!!!
So I followed along and there was a browser error. WHAT?
my current code: 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>You guessed the number!</p>'); } else { document.write('<p>Sorry. The number was ' + randomNumber + '</p>); }
Help!
3 Answers

Steven Parker
225,712 Points It looks like your problem is a missing closing quote on your last string. You probably meant:
document.write('<p>Sorry. The number was ' + randomNumber + '</p>'); // <- quote added at end

Marco Boretto
29,821 PointsMath.floor(Math.random() * 6 ) + 1 always generates 1 if you want to generate a random number between 1 and 6 try this :
Math.floor(Math.random()*6+1)

Steven Parker
225,712 PointsActually, both of those do exacty the same thing - it makes no difference if you add a whole number inside or outside the floor function.

Marco Boretto
29,821 Pointsi think you missed an ' at the end of else { document.write('<p>Sorry. The number was ' + randomNumber + '</p>); }