Ad
  • Custom User Avatar

    1.) punctuation.indexOf(pin) === 0 is your problem because it attempts to find the whole pin in the punctuation array. For example it tries to find .234 in the array instead of ..

    2.) isNaN(pin) will work on a string of digits that contains a letter because that can be converted to bases such as hexadecimal. You need to check if any letters are in the string.

  • Custom User Avatar

    It terminates because of an infinite loop when a > b.
    Try with the following cases

    GetSum(0, -1)  // -1
    GetSum(5, 1)   // 15
    GetSum(5, -1)  // 14