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 trialKatharine Cooney
4,612 PointsCan't get my generator to work!
I've watched the video over and over and I think I've copied the exact code used in the video but neither my prompt nor my message appear in the preview. If anyone could help me, I'd be forever grateful!
var input = prompt("Please type a number");
var topNumber = parseInt(input);
var randomNumber = Math.floor(Math.random() * topNumber) + 1;
var message = "<p>" + randomNumber + “ is a number between 1 and ” + topNumber + “.</p>";
document.write(message);
2 Answers
Umesh Ravji
42,386 PointsHi Katharine, your code appears fine except for some reason the quotes you've ended up with in some places are not the double quotes that you need to use, such as “
, just stick to using "
.
var input = prompt("Please type a number");
var topNumber = parseInt(input);
var randomNumber = Math.floor(Math.random() * topNumber) + 1;
var message = "<p>" + randomNumber + " is a number between 1 and " + topNumber + ".</p>";
document.write(message);
Katharine Cooney
4,612 PointsHi Umesh,
Thanks so much! That's really strange that my quotes were changing, but I just went back and fixed my quotes and now my code runs smoothly. Thanks again!