DEV Community


Discussion on: Generate and Set Pseudorandom Hexadecimal Background Color Using JavaScript

craigmc08 profile image
Craig McIlwrath

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)