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 – Solution

Bolivar Arguello
seal-mask
.a{fill-rule:evenodd;}techdegree
Bolivar Arguello
Front End Web Development Techdegree Student 9,429 Points

Here's my solution

// Collect input from a user

// Convert the input to a number

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

// Create a message displaying the random number

let inputHigh = parseInt(prompt('Enter a number 1 thru 6.')); let randomNumber = Math.floor( Math.random() * 6) + 1; //Math.random() will generate a random number //ParseInt will convert user input into an integer number //and it will prevent me from creating an extra variable //also I made use of if statements to combine what I already learned with JS.

if(inputHigh === randomNumber) { console.log("you gess correct"); } else { console.log(the correct nnnumber ${randomNumber} || your input ${inputHigh});; }