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 Numbers The Math Object Random Number Challenge

Tamella Hajiyeva
seal-mask
.a{fill-rule:evenodd;}techdegree
Tamella Hajiyeva
Full Stack JavaScript Techdegree Student 6,678 Points

My code for this assignment

// Collect input from a user const input = prompt ('Please enter any number')

// Convert the input to a number const conversion = +input

// Use Math.random() and the user's number to generate a random number

let result = Math.floor(Math.random() * conversion) +1; // Create a message displaying the random number

console.log(result) alert(result); document.querySelector('main').innerHTML= You just entered randomly ${result};

1 Answer

Mark Casavantes
Mark Casavantes
2,880 Points

Hello Tarmella,

Where do you collect input from the user? You need back ticks You just entered randomly ${result}; Your variable "conversion" is not defined. Your variable "innerHTML" is not defined.

I hope this helps you.