By Hunter Becton on January 21, 2023
const isHexColor = (hex) => {
const regex = /^#?([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/;
return regex.test(hex);
}
This function returns true
or false
depending if the value passed in follows the hexadecimal color code syntax.