Created
October 16, 2021 11:40
-
-
Save Asgarrrr/ed08b27ed4ffcf56c117d0fcc78d0a77 to your computer and use it in GitHub Desktop.
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 ) => "#" + [ r, g, b ].map( ( x ) => { | |
const hex = x.toString( 16 ) | |
return hex.length === 1 ? "0" + hex : hex | |
}).join( "" ); | |
rgbToHex( 102, 51, 153 ); // #663399 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment