UNPKG
random-integer
Version:
latest (2.0.0)
2.0.0
1.0.1
1.0.0
generate a random integer
github.com/joaquimserafim/random-integer
joaquimserafim/random-integer
random-integer
/
index.js
11 lines
(8 loc)
•
194 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
'use strict'
module
.
exports
= randomInteger
function
randomInteger
(
int1, int2 =
0
) {
return
Math
.
floor
(
Math
.
random
() * (
Math
.
abs
(int1) -
Math
.
abs
(int2) +
1
) +
Math
.
abs
(int2) ) }