Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Very satisfying to finish this, a tip for anyone stuck on the fibonacci sequence: read the instructions for this kata VERY carefully.
This comment is hidden because it contains spoiler information about the solution
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.
This comment is hidden because it contains spoiler information about the solution