Sometimes you have the RGB color code but you just really want the Hex code, right? Well converting RGB to Hex is so easy in JavaScript!
const rgb2hex = (r, g, b) => {
return '#' +
(
(1 << 24) +
(r << 16) +
(g << 8) +
b
)
.toString(16).slice(1);
};
console.log(rgb2hex(0, 0, 0));
Top comments (0)