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 trialChristian Solorzano
6,606 PointsWhat's wrong with my code?
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);
Nothing shows up in my browser.
3 Answers
ivannnnn
58 PointsYou are missing some quotes in your message variable. This is correct: ''' var message = "<p> " + randomNumber + " is a number between 1 and " + topNumber +".</p>"; ''' You need to use the console.
Gregory Katchmar
10,912 PointsLine 3: You need a ) after "+1".
Line 4: Need a " after "between 1 and[space]
Need another " after ".<p>
Christian Solorzano
6,606 Pointsvar 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);
like this?
Gregory Katchmar
10,912 PointsShould be: " is a number between 1 and "+ topNumber +".</p>";
Use quotes to encircle text and HTML tags; variables cannot be within quotes.
Don't worry, with enough repetition, it will soon become second nature.