Created
October 5, 2021 07:07
-
-
Save ialeke/83301236b9e8a86845e77662c514eefc to your computer and use it in GitHub Desktop.
create dynamic hex color from string
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
function convert(string) { | |
const color = Number( | |
string | |
.split("") | |
.map((f) => f.charCodeAt(0)) | |
.join("") | |
) | |
.toString(16) | |
.toUpperCase() | |
.slice(0, 6); | |
return `#${color}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment