Last active
June 20, 2022 03:40
-
-
Save tzwel/b7e75dc7115245fd38ea82c086742a6e to your computer and use it in GitHub Desktop.
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
const numjs = (function () { | |
// Get a random number in range, accept generating multiple numbers optionally converted to a single Number | |
function range(min, max, times = 1, convert = false) { | |
let generatedNumber = Math.floor(Math.random() * (max - min + 1) + min) | |
if (times > 1) { | |
for (let i=1; i< times; i++) { | |
generatedNumber += Math.floor(Math.random() * (max - min + 1) + min).toString() | |
} | |
} | |
if (convert) { | |
generatedNumber = Number(generatedNumber) | |
} | |
return generatedNumber | |
} | |
// Return current unix time timestamp | |
function time() { | |
return Date.now() | |
} | |
return { range, time } | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment