We can use JavaScript functions to generate a random number.
This can be done using the math dot random function.
This function will generate a number between 0 and 1.
Let's take a look at how it works.
Using this example script
here we're using the get element by idea output method to output a random number.
And there's the math dot random function.
Let's go ahead and save the file and preview it in our web browser.
Here we can see a random number is generated.
If we refresh the page it'll generate different random numbers.
The value is always between 0 and 1.