Skip to content

Instantly share code, notes, and snippets.

@danhollick
Last active February 5, 2020 17:30
Show Gist options
  • Save danhollick/e00c2d636d0d4ed1ee0b9fe6788e6dda to your computer and use it in GitHub Desktop.
Save danhollick/e00c2d636d0d4ed1ee0b9fe6788e6dda to your computer and use it in GitHub Desktop.
RGB to Hex
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