The substring() method extracts the characters from a string, between two specified indices, and returns the
You're confusing substring() and substr(): substring() expects two indices and not offset and length.
Using substring() with length property. Replacing a substring within a string. Specifications.