Skip to content

Instantly share code, notes, and snippets.

@andrejsharapov
Last active September 14, 2022 07:29
Show Gist options
  • Save andrejsharapov/19af154fc9703c98d8fa9115bd30c432 to your computer and use it in GitHub Desktop.
Save andrejsharapov/19af154fc9703c98d8fa9115bd30c432 to your computer and use it in GitHub Desktop.
methods: random - size, - color, - text
const randomColor = () => {
const min = Math.ceil(0);
const max = Math.floor(360);
const hue = Math.floor(Math.random() * (max - min)) + min;
return `hsl(${hue}, 50%, 50%)`;
};
const randomSize = () => {
const random = Math.floor(Math.random() * (200 - 50)) + 50;
return random;
};
const makeCode = (n) => {
n = 10;
let randText = "";
const possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < n; i++)
randText += possible.charAt(Math.floor(Math.random() * possible.length));
return randText;
};
this.randCode = {
code: makeCode(),
};
console.log(this.randCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment