Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  183] [ 5]  / answers: 1 / hits: 116451  / 15 Years ago, mon, february 1, 2010, 12:00:00

for my selenium tests I need an value provider to get a 5-digit number in every case. The problem with javascript is that the api of Math.random only supports the generation of an 0. starting float. So it has to be between 10000 and 99999.



So it would be easy if it would only generates 0.10000 and higher, but it also generates 0.01000. So this approach doesn't succeed:



Math.floor(Math.random()*100000+1)


Is it possible to generate a 5-digit number in every case (in an expression!) ?


More From » random

 Answers
3

What about:



Math.floor(Math.random()*90000) + 10000;

[#97694] Thursday, January 28, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keyonnal

Total Points: 746
Total Questions: 103
Total Answers: 116

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
;