How to return a random number in javascript which is always greater then the previous number -
how can return random number in javascript greater previous random number every time code reruns. example when code runs first time returns 1000 , when runs second time returns 1300.
conditions: number must integer.
function randomfunction() { var x = 0 return function() { x = x + math.round( math.random() * 100 ) return x } } var nextrandom = randomfunction() nextrandom() // => 51 nextrandom() // => 127 nextrandom() // => 203
Comments
Post a Comment