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.
cough Java cough
I don't get why they don't just incorporate this into JavaScript. JavaScript's basic sort function is inexcusably stupid.
It would still be possible to hardcode the 'double-alphabet' solution and then run not-quite-valid code until it passes, currently. A few more randomized tests would help. Other than that, good kata :) Took me a while as I was apparently unaware of the full extent to the weirdness of JS's sorting algorithm.
Couple observations for the future:
Test
library functions, notablyrandomToken
andrandomize
. You can find these under Docs -> Kata Test Framework -> JS/CoffeeScript Test Reference. That doesn't mentionassertDeepEquals
andassertApproxEquals
, but they work comparably toassertEquals
.Object
s (includingArray
s) as arguments, be careful to pass copies, unless you want user to be able to change the argument and have the reference solution work on the changed argument. Not an issue with primitives (String
s,Number
s,Boolean
s), unless passed as anObject
(which is exceedingly rare).Yep, works. :]
One random test is enough really, but having 50 is essentially free with a
for
loop.Strict mode is mostly about bad use cases of context (
this
).If you have to worry about automatic semicolon insertion then... go study about it and know what the actual ASI rules are? Because not even adding semicolons to every line will help you against some wrong programs due to how ASI work.
http://inimino.org/~inimino/blog/javascript_semicolons