Skip to content

Instantly share code, notes, and snippets.

@ialeke
Created October 5, 2021 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ialeke/83301236b9e8a86845e77662c514eefc to your computer and use it in GitHub Desktop.
Save ialeke/83301236b9e8a86845e77662c514eefc to your computer and use it in GitHub Desktop.
create dynamic hex color from string
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