changeLightness
Changes the lightness value of an hsl()
color string.
- Use
String.prototype.match()
to get an array of 3 strings with the numeric values. - Use
Array.prototype.map()
in combination withNumber
to convert them into an array of numeric values. - Make sure the lightness is within the valid range (between
0
and100
), usingMath.max()
andMath.min()
. - Use a template literal to create a new
hsl()
string with the updated value.