getColorFromString builds its hash with acc * 31 + charCodeAt(0), which overflows to Infinity for a long enough string. hash % 360 is then NaN, so it returns an invalid color:
getColorFromString("n".repeat(300)) // -> "hsl(NaN, 100%, 50%, 1)"
A hue of NaN is not a parseable color. It should return a valid hue for any input string.
getColorFromStringbuilds its hash withacc * 31 + charCodeAt(0), which overflows toInfinityfor a long enough string.hash % 360is thenNaN, so it returns an invalid color:A hue of
NaNis not a parseable color. It should return a valid hue for any input string.