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.
From tooling's perspective, it is a good practice. While the return type can be inferred, the parameter's could normally be anything which is safe to convert to a number:
Gotta type those arguments.
I just tested this and it seems to be working fine. I would go back and give your code another once over.
Good luck!
Inexplicably breaks for me on random tests. Copied and pasted:
Random Tests
ReferenceError: k is not defined
at Object.Test.describe
This comment is hidden because it contains spoiler information about the solution
Hey, I posted a longer response to another comment in the thread , but it's rounding the number down to an integer.
Rounding the number down to an integer.
~
is the bitwise NOT operator. It flips all the zeros to ones and ones to zeros in a number. But when you do it, JS doesn't use the Floating Point representation of the number, it uses the integere representation. So really~n
means "Instead of a Number, treatn
like a string of bits and flip all of those." Then I just do it again to flip it back and I have the integer representation.For future reference, you can search for symbols on Symbolhound if you see something like this. For instance that's where I learned what
::
means in C++ and PHP. It's also where I found this better explanation of ~~ if you want to see another take on this.Happy coding friend!
Would also be interested to no exactly what's going on here.