Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Normally I'd say yes, giving parseInt a radix of 10 is best form. However, you really only have to worry about specifying a radix if the string could possibly have a leading "0x" or "0". E.g.

    parseInt("0x10"); // -> 16
    parseInt("010"); // -> 10 or 8, depending on implementation
    

    Both of those are impossible in this case: we know that the string is a number in string form and the digits are sorted in descending order, so it can't possibly begin with "0x" or "0" (unless the number is 0, and then the radix is irrelevant).

    I prefer +n anyway in most cases, because you can test that the result isn't NaN. parseInt and parseFloat provide no error handling whatsoever.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution