Error AtlasError Documentation and Resolution

JavaScript string repeat count was negative

RangeError: repeat count must be non-negative

JavaScript rejected a string repeat operation because the repeat count was negative.

RangeError: repeat count must be non-negativeruntime
RangeError: repeat count must be non-negative
  • String.repeat received a negative number.
  • Math or parsing logic produced a negative count unexpectedly.
  • User-controlled input was passed into repeat() without validation.
  1. Check that repeat counts are zero or greater before calling repeat().
  2. Normalize or reject invalid user input that can become negative.
  3. Review numeric transformations that might flip the sign of the repeat count.
MDN: RangeError: repeat count must be non-negative
JavaScript repeat count must be non-negative | Error Atlas