Ad
  • Custom User Avatar

    cough Java cough

  • Custom User Avatar

    I don't get why they don't just incorporate this into JavaScript. JavaScript's basic sort function is inexcusably stupid.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Couple observations for the future:

    • Description Example backtick backtick backtick "js" would be "javascript". I've changed that. Won't matter until translations come into play; "js" works for syntax highlighting but not for language specific blocks.
    • Random argument generation could benefit from some Test library functions, notably randomToken and randomize. You can find these under Docs -> Kata Test Framework -> JS/CoffeeScript Test Reference. That doesn't mention assertDeepEquals and assertApproxEquals, but they work comparably to assertEquals.
    • If and when you have to pass Objects (including Arrays) 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 (Strings, Numbers, Booleans), unless passed as an Object (which is exceedingly rare).
  • Custom User Avatar

    Yep, works. :]

    One random test is enough really, but having 50 is essentially free with a for loop.

  • Custom User Avatar

    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