1
00:00:00,120 --> 00:00:03,860
We can use JavaScript functions to generate a random number.

2
00:00:03,960 --> 00:00:08,400
This can be done using the math dot random function.

3
00:00:08,520 --> 00:00:12,420
This function will generate a number between 0 and 1.

4
00:00:12,450 --> 00:00:14,120
Let's take a look at how it works.

5
00:00:14,160 --> 00:00:15,480
Using this example script

6
00:00:20,220 --> 00:00:28,520
here we're using the get element by idea output method to output a random number.

7
00:00:29,010 --> 00:00:33,190
And there's the math dot random function.

8
00:00:33,260 --> 00:00:39,260
Let's go ahead and save the file and preview it in our web browser.

9
00:00:39,290 --> 00:00:42,750
Here we can see a random number is generated.

10
00:00:43,460 --> 00:00:49,290
If we refresh the page it'll generate different random numbers.

11
00:00:49,400 --> 00:00:51,790
The value is always between 0 and 1.
