Created
September 30, 2021 10:05
-
-
Save chankruze/5b0b2d86d3788b3bebf5ef4e4ae966ea to your computer and use it in GitHub Desktop.
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 rgb2hex = (...args) => { | |
const hexColour = (c) => { | |
if (c < 256) return Math.abs(c).toString(16).padStart(2, "0"); | |
return 0; | |
} | |
let hex = "#"; | |
args.forEach(val => hex += hexColour(val)) | |
return hex | |
} | |
console.log(rgb2hex(10, 255, 255)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment