re: Generate and Set Pseudorandom Hexadecimal Background Color Using JavaScript VIEW POST


Have you considered using .toString(16)? Also, what about just using actual CSS integer RGB values instead of hex? Seems like either could simplify this. :)


toString(16) has the problem of numbers like 14 ending up being one character long, so you need a left pad function. rgb color values are the best solution, imo (or hsl)

code of conduct - report abuse