Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Generate random number

kc
Level 8
Level 8
Hi all,



Does anyone know how I can generate a random number?



My idea is that I can create a loop for handling the indexes of a string one by one, but I don't know if it is possible to get a single random number.



Of course I could create my own custom service as well, but I would like to use the stand alone services first and fore most if it is possible.



Is it possible without a custom service?



Thanks in advance



Sincerely

Kim
2 Replies
pguerett
Level 10
Level 10
There are functions in Javascript for this. Did a search on the web and come up with this one:



var num=Math.floor(Math.random()*1000)



Where num will contain a random number between 0 and 1000. If you want a different range change the 1000 to your max range.
kc
Level 8
Level 8
Thanks a lot Paul, that is very usefull, allthough I would have liked it to be possible without using the script-service.



Thanks again, I really appreciate it



Sincerely

Kim