[bug] change Array.slice() for String.slice()
useage: Array.slice() should be changed to String.slice()
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
Extends a 3-digit color code to a 6-digit color code.
|
Extends a 3-digit color code to a 6-digit color code.
|
||||||
|
|
||||||
Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for converting a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
|
Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for converting a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
|
||||||
`Array.slice()` is used to remove `#` from string start since it's added once.
|
`String.slice()` is used to remove `#` from string start since it's added once.
|
||||||
```js
|
```js
|
||||||
const extendHex = shortHex =>
|
const extendHex = shortHex =>
|
||||||
'#' + shortHex.slice(shortHex.startsWith('#') ? 1 : 0).split('').map(x => x+x).join('')
|
'#' + shortHex.slice(shortHex.startsWith('#') ? 1 : 0).split('').map(x => x+x).join('')
|
||||||
|
|||||||
Reference in New Issue
Block a user