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
Ben Mohammad
5,659 PointsBummer prompt dont show. Any help out there?
can someone elaborate on where im going wrong......?
var randomNumber - Math.floor(Math.random() * 6) + 1; var guess = prompt('I am thing of a number between q and 6. What is it?'); if (parseInt(guess) === randomNumber){ document.write('<p>You guessed right!</p>); } else { document.write('<p>Sorry. The number was ' + randomNumber + '</p>); }
1 Answer
Thomas Nilsen
14,957 PointsYou were missing some minor things. two of these: ', and when you declare a variable you wrote - instead of =
Here is the changed code:
var randomNumber = Math.floor(Math.random() * 6) + 1;
var guess = prompt('I am thing of a number between q and 6. What is it?');
if (parseInt(guess) === randomNumber) {
document.write('<p>You guessed right!</p>');
} else {
document.write('<p>Sorry. The number was ' + randomNumber + '</p>');
}
Mindy Sandilands
15,743 PointsMindy Sandilands
15,743 PointsLooks like it may be a simple syntax error.
var randomNumber - Math.floor(Math.random() * 6) + 1;
Should be
var randomNumber = Math.floor(Math.random() * 6) + 1;
You have a hyphen instead of the equal sign. Let me know if that doesn't work.