题解 | #颜色字符串转换#
颜色字符串转换
http://www.nowcoder.com/practice/80b08802a833419f9c4ccc6e042c1cca
function rgb2hex(sRGB) { let str = '#' var temp sRGB.slice(4, -1).split(',').forEach((value) => { temp = parseInt(value.trim()).toString(16) str += temp.length == 1 ? '0' + temp : temp }) if (str === '#NaN') return sRGB return str }