Last active
February 3, 2017 08:18
-
-
Save b-rucel/1674717b1f4744a3a328af161bfd0995 to your computer and use it in GitHub Desktop.
javascript random number with min/max range and incremental number set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function random_number_increment( min, max, inc ) { | |
let min = min || 0; | |
let inc = inc || 1; | |
if ( !max ) { | |
return new Error( 'Need to define max' ); | |
} | |
return Math.floor( Math.random() * ( max - min ) / inc ) * inc + min; | |
} | |
random_number_increment( 200, 2000, 25 ) // 200, 225, 250 ... 1975, 2000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment