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 JavaScript Basics (Retired) Working With Numbers The Random Challenge Solution

John Paul Luna
John Paul Luna
1,624 Points

Code will not display in brackets, even though other exercises have.

/* "random number generator" for treehouse course J. Paul Luna 08 Sept 16 */

alert('This is a user driven random number generator. ');
var userNumberInput = prompt('Please enter a random number.');
var topNumber = parseInt(userNumberInput);
alert('You selected the number: ' + userNumberInput);
var randomNumber = Math.floor(Math.random() * topNumber) + 1;
var message =  "<p>" randomNumber " is a number between 1 and " + topNumber + ".</p>";
document.write(message);

I made sure to change the index.html to reflect this .js file.

Damien Watson
Damien Watson
27,419 Points

Sorry, what do you mean by 'Code will not display in brackets'?

1 Answer

Damien Watson
Damien Watson
27,419 Points

Hi, you're missing a few '+' symbols for concatenation:

var message =  "<p>" + randomNumber + " is a number between 1 and " + topNumber + ".</p>";