Created
August 9, 2017 23:08
-
-
Save mattmattmatt/d1b578a14ff7407c865bd0d75974df5d to your computer and use it in GitHub Desktop.
Returns a sufficiently random identifier
This file contains hidden or 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 randomIntFromInterval(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function getRandomName() { | |
const names = [ | |
'Bear', | |
'Monkey', | |
'Space', | |
'Bird', | |
'Lion', | |
'House', | |
'Car', | |
'Rocket', | |
'Funk', | |
'Music', | |
'Bike', | |
'Shoe', | |
'Litter', | |
'Police', | |
'Fire', | |
'Stone', | |
'Giraffe', | |
'Baby', | |
]; | |
return `${names[randomIntFromInterval(0, names.length - 1)]}-${names[ | |
randomIntFromInterval(0, names.length - 1) | |
]}-${names[randomIntFromInterval(0, names.length - 1)]}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment