Last active
February 5, 2020 17:30
-
-
Save danhollick/e00c2d636d0d4ed1ee0b9fe6788e6dda to your computer and use it in GitHub Desktop.
RGB to Hex
This file contains hidden or 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
function convertRgbToHex(color) { | |
const { r, g, b } = color | |
const hex = [r, g, b] | |
.map(col => { | |
const hexColor = normalizedColor.toString(16) | |
return `0${hexColor}`.slice(-2) | |
}) | |
.join('') | |
return `#${hex}` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment