numToOrdinal
uses a bunch of .lastIndexOf()
checks. It seems like the coder thought this function checked if the supplied value was at the end of the string, but it actually checks for the last time it appears in the string, so you end up with things like "14st" because "14".lastIndexOf("1")
will return 0, not -1.Switch out the tests for something like
.endsWith("1")
.
Last edited: