Skip to content

Instantly share code, notes, and snippets.

@justyn-clark
Created November 14, 2018 02:11
Show Gist options
  • Save justyn-clark/b3af9bb446d2e8dcc8fa40eae57cff9a to your computer and use it in GitHub Desktop.
Save justyn-clark/b3af9bb446d2e8dcc8fa40eae57cff9a to your computer and use it in GitHub Desktop.
let color = 'fffff'
let newColor = ''
if (!color.includes('#')) {
newColor = insert(color, 0, "#")
}
function insert(str, index, value) {
return str.substr(0, index) + value + str.substr(index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment