Random number generator doesn't work

So, I have this random number generator that generates a random number after the user clicks the ‘Generate & List Number!’ button, and each time the user clicks it, the numbers change except they don’t unless you refresh the page.

I tried Googling it up, but couldn’t find what I’m looking for.

Here's the pen/code for the project

Random Number Generator

Math.random() is called in the global space, which is called only when the page is loaded for the first time. If you want it to give a different value each time that the button is pressed, you need to use it in the function that is called when the button is pressed

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.