Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Random Number Challenge1:14 with Guil Hernandez
It's time for another programming challenge! In this challenge, you'll create a random number generator. It should collect a number from a user, then print a random number from 1 up to the user's provided number.
- Collect a user's input.
- Convert that input from a string to a number. This will be the highest possible random number in the range of numbers starting from 1.
- Use the
Math.random()method to create a random number using the number provided by the user.
- Create a message displaying the random number. You can use any method you want to display the message. For instance, print it to the console, display it on the page, or with an alert.
You also learned how to create random numbers.
I think you’re ready for a programming challenge.
In this challenge, you’ll create a random number generator.
It should collect a number from a user then print a random number from one
up to the users provided number.
To get started, launch the new workplace with this video.
In the file random.js,
I've included comments with instructions on what you'll need to do.
You'll use some of the concepts you've learned so far to complete this challenge.
First, you'll need to collect a user's input,
then convert that input from a string to a number.
This will be the highest possible random number in the range of numbers
starting from 1.
Then use the Math.random method
to create a random number using the number provided by the user.
Finally you'll create a message displaying the random number.
You can use any method you want to display the message.
For instance, printed to the council, displayed on the page or with an alert.
The goal is to get your program to work similarly to this.
So good luck, have fun, and in the next video, I'll show you how I did it.
You need to sign up for Treehouse in order to download course files.Sign up