Ad
  • Custom User Avatar

    Take a = "a", b = "b" as an example

    The conditional statement will compare it like this ("A" === "a" || "b" === "B"). Clearly, both of them are not equal, so any alphabetical letters (a-z and A-Z) will not enter this part of the control flow statement. Whilst, if you compare any non-alphabetical letters, (~ / ! / ?), changing of casing does not affect them, so the condition will be as such:

    '~' === '~' || '!' === '!' // assuming a = '~' and b = '!'
    

    which will always evaluate to true, hence returning -1

  • Custom User Avatar

    Use spoiler flag next time please.

  • Custom User Avatar

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

  • Custom User Avatar

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