Skip to content

Instantly share code, notes, and snippets.

@jonasmello
Created October 11, 2023 18:39
Show Gist options
  • Save jonasmello/102b12c4524eba92b9e5a031cab70914 to your computer and use it in GitHub Desktop.
Save jonasmello/102b12c4524eba92b9e5a031cab70914 to your computer and use it in GitHub Desktop.
Gerador de Cores e Imagem para placeholder
const a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'];
const genCol = (length = 6) => {
let text = '';
if (length > 1) {
for (let i = 0; i < length; i++) {
text += `${a[Math.floor(Math.random() * 15)]}`;
}
}
return text;
};
const genImg = () =>
`https://dummyimage.com/${200 + Math.floor(Math.random() * 200 + 1)}x${
200 + Math.floor(Math.random() * 200 + 1)
}/${genCol()}/${genCol()}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment