Created
October 2, 2021 21:46
-
-
Save sayyedhammadali/98122a2a542e9b3165e5fa1df18a725f to your computer and use it in GitHub Desktop.
Convert RGB to Hex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rgbToHex = (r, g, b) => "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | |
rgbToHex(0, 51, 255); | |
// Result: #0033ff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment