Random number generator multiple times with one command (without copy/paste)

Asked Feb 15, 2022·4 replies·Last activity 4 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Here is the code to generate a random number between 1 and 10: $(eval Math.floor((Math.random() * 10) + 1))

How would I alter this so that it loops and picks a random number between 1 and 10 over and over again until it spits out 50 results.

4 replies

This should do what you want

$(eval x=``;for(a=0;a<50;a++){y=Math.floor(Math.random()*10)+1;x+=y+` `}x)

Worked perfectly, thank you very much!

Is it possible to have it not repeat numbers, if not its fine.

Yes that would be possible but to be clear that would only be 10 results not 50 or do you mean not multiple of the same numbers.