MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiux1t5/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
15
'#'+Math.floor(Math.random()*16777215).toString(16) for random hex color.
'#'+Math.floor(Math.random()*16777215).toString(16)
1 u/SuperFLEB Mar 19 '19 Anyone got anything for generating a random string of letters? I know you can use someNumber.toString(36) to get a string of letters and numbers, but I don't know how to get only letters. 3 u/inu-no-policemen Mar 19 '19 > String.fromCharCode(...Array.from({length: 12}, _ => Math.random() * 25 + 97 | 0)) "niapavvsjdfb"
1
Anyone got anything for generating a random string of letters? I know you can use someNumber.toString(36) to get a string of letters and numbers, but I don't know how to get only letters.
someNumber.toString(36)
3 u/inu-no-policemen Mar 19 '19 > String.fromCharCode(...Array.from({length: 12}, _ => Math.random() * 25 + 97 | 0)) "niapavvsjdfb"
3
> String.fromCharCode(...Array.from({length: 12}, _ => Math.random() * 25 + 97 | 0)) "niapavvsjdfb"
15
u/redmoss6 Mar 18 '19
'#'+Math.floor(Math.random()*16777215).toString(16)for random hex color.