Skip to content

Commit ac30336

Browse files
committed
fix: change function code to concise format
1 parent 7067951 commit ac30336

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Conversions/RgbHslConversion.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@
1515
* // result = [193, 66, 28]
1616
*/
1717

18-
const checkRgbFormat = (colorRgb) => {
19-
if (colorRgb[0] <= 255 && colorRgb[0] >= 0) {
20-
if (colorRgb[1] <= 255 && colorRgb[1] >= 0) {
21-
if (colorRgb[2] <= 255 && colorRgb[2] >= 0) {
22-
return true
23-
}
24-
}
25-
}
26-
return false
27-
}
18+
const checkRgbFormat = (colorRgb) => colorRgb.every(c => c >= 0 && c <= 255);
2819

2920
const rgbToHsl = (colorRgb) => {
3021
if (checkRgbFormat(colorRgb) === false) {
@@ -91,4 +82,4 @@ const rgbToHsl = (colorRgb) => {
9182
return colorHsl
9283
}
9384

94-
export { rgbToHsl }
85+
export { rgbToHsl }

0 commit comments

Comments
 (0)