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.
To make the challenges more challenging for me I'm aiming for minimal code instead of product quality code ;)
This comment is hidden because it contains spoiler information about the solution
It's a Double NOT bitwise operator. So
~~undefined
or~~null
becomes a0
.A more readable approach would be to just use
a.pop() || 0
No issue being proud of your code, but the solution above is by far the most readable out of all of them, simple if statements and one standard for loop. It isn't quite as fast as the most optimized code but in most cases this is best practice.
I think you nailed in in your comments, the code in your solution is very much coded for this specific solution but does remove that extra step.
Scans the array to determine the first and list instance of an element (this is done by comparing the indices). Whenever it matches you have found the unique element.
Your code is incorrect and this is not a kata issue (= a bug in the kata).
IMO a walk.forEach() would be even cleaner.
I rarely if ever use for-loops anymore.
Declarative code is just so much easier to read and understand.
Please use the
spoiler
tag next time :D