Skip to content

Instantly share code, notes, and snippets.

@mattmattmatt
Created August 9, 2017 23:08
Show Gist options
  • Save mattmattmatt/d1b578a14ff7407c865bd0d75974df5d to your computer and use it in GitHub Desktop.
Save mattmattmatt/d1b578a14ff7407c865bd0d75974df5d to your computer and use it in GitHub Desktop.
Returns a sufficiently random identifier
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