Last active
September 14, 2022 07:29
-
-
Save andrejsharapov/19af154fc9703c98d8fa9115bd30c432 to your computer and use it in GitHub Desktop.
methods: random - size, - color, - text
This file contains 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
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%)`; | |
}; |
This file contains 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
const randomSize = () => { | |
const random = Math.floor(Math.random() * (200 - 50)) + 50; | |
return random; | |
}; |
This file contains 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
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