Ad
  • Custom User Avatar

    Very satisfying to finish this, a tip for anyone stuck on the fibonacci sequence: read the instructions for this kata VERY carefully.

  • Custom User Avatar

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

  • Custom User Avatar

    The ~ operator is a bitwise operator, without going into to much detail, it simply inverts the binary bits of the expression in front of it. This is from the mozilla docs: 'Bitwise NOTing any number x yields -(x + 1). For example, ~-5 yields 4.'

    pin.indexOf('.') will return a -1 if the '.' is not in the pin. -1 is considerly a falsy value, so by using the bitwise NOT operator (~) on -1 the result equates to ~-1 = -(-1 + 1) = 0. And by using the logical NOT operator (!) it inverts the falsy value of 0 into a truthy value of 1.

    !~pin.indexOf('.') could be very easily replaced with something more readable like !pin.includes('.').

    I hope this makes sense.

  • Custom User Avatar

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