isHexColor()
function isHexColor(hex): boolean
Check if a string is a valid hex color
Parameters
Parameter | Type | Description |
---|---|---|
hex | string | The string to check |
Returns
boolean
True if the string is a valid hex color, false otherwise
Example
isHexColor('#FF0000'); // true
isHexColor('#FF000000'); // true
isHexColor('#GHIJKL'); // false