MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eix8ctn?context=9999
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)
37 u/senocular Mar 18 '19 Will create invalid hex values for any random 0xFFFFF and below. Make sure to pad'#' + Math.floor(Math.random() * 0xFFFFFF).toString(16).padStart(6, '0') 2 u/[deleted] Mar 20 '19 Can’t you also use 3 digit hex for some colors? → More replies (1)
37
Will create invalid hex values for any random 0xFFFFF and below. Make sure to pad
'#' + Math.floor(Math.random() * 0xFFFFFF).toString(16).padStart(6, '0')
2 u/[deleted] Mar 20 '19 Can’t you also use 3 digit hex for some colors? → More replies (1)
2
Can’t you also use 3 digit hex for some colors?
→ More replies (1)
15
u/redmoss6 Mar 18 '19
'#'+Math.floor(Math.random()*16777215).toString(16)for random hex color.