diff --git a/snippets/3-digit-hexcode-to-6-digit-hexcode.md b/snippets/3-digit-hexcode-to-6-digit-hexcode.md index a138b34bb..17a4561db 100644 --- a/snippets/3-digit-hexcode-to-6-digit-hexcode.md +++ b/snippets/3-digit-hexcode-to-6-digit-hexcode.md @@ -4,8 +4,7 @@ Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for con ```js const convertHex = shortHex => - shortHex[0] == '#' ? ('#' + shortHex.slice(1).split('').map(x => x+x).join('')) : - ('#' + shortHex.split('').map(x => x+x).join('')); + '#' + shortHex.slice(shortHex.startsWith('#') ? 1 : 0).split().map(x => x+x).join() // convertHex('#03f') -> '#0033ff' // convertHex('05a') -> '#0055aa' ```