(r, g, b)
| 1 | function RGBToHex(r, g, b) { |
| 2 | if (typeof r !== 'number' || typeof g !== 'number' || typeof b !== 'number') { |
| 3 | throw new TypeError('argument is not a Number') |
| 4 | } |
| 5 | |
| 6 | const toHex = (n) => (n || '0').toString(16).padStart(2, '0') |
| 7 | |
| 8 | return `#${toHex(r)}${toHex(g)}${toHex(b)}` |
| 9 | } |
| 10 | |
| 11 | export { RGBToHex } |
| 12 |