function isHexColor(string) {
  return string.trim().search(/^#([\da-fA-F]{3}|[\da-fA-F]{6})$/) !== -1;
}
Checks if the input string is a hex color value

@param {String} string - the input
@return {Boolean} true, if the input is a hex color