We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51cf96c commit 1e27f30Copy full SHA for 1e27f30
Conversions/RGBToHex.js
@@ -0,0 +1,16 @@
1
+function RGBToHex (r, g, b) {
2
+ if (
3
+ typeof r !== 'number' ||
4
+ typeof g !== 'number' ||
5
+ typeof b !== 'number'
6
+ ) {
7
+ throw new TypeError('argument is not a Number')
8
+ }
9
+
10
+ const toHex = n => (n || '0').toString(16).padStart(2, '0')
11
12
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`
13
+}
14
15
+console.log(RGBToHex(255, 255, 255) === '#ffffff')
16
+console.log(RGBToHex(255, 99, 71) === '#ff6347')
0 commit comments