Skip to content

Instantly share code, notes, and snippets.

@levchenkod
Last active June 3, 2020 21:13
Show Gist options
  • Save levchenkod/bddfbdc5fb06d9f3d96d45c129519837 to your computer and use it in GitHub Desktop.
Save levchenkod/bddfbdc5fb06d9f3d96d45c129519837 to your computer and use it in GitHub Desktop.
Random ava url generator
const random = (max) => {
return Math.floor(Math.random() * max);
};
const getRandomAvaURL = () => {
const source = 'https://randomuser.me/api/portraits';
const gender = ['women', 'men'][random(2)];
const count = 100;
const id = random(count);
const extention = 'jpg';
return `${source}/${gender}/${id}.${extention}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment