5 kyu

Argument Mapper

Description
Loading description...
Reflection
Fundamentals
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar
    • No random tests

    • Node 12 should be enabled

  • FArekkusu Avatar

    Tests are using Test.expect.

  • user5200009 Avatar

    Fool's kata. Waste of time. You cannot depend on parameter names in JavaScript. Give up now.

    • ohager Avatar

      You cannot, that's true. But this is a dojo here... and the kata should give you an insight. btw: In Karate you won't defend yourself running a kata (e.g. Empi or Unsu) when you gonna beaten up by some rude guys.

    • user5200009 Avatar

      Broken analogy. Dojos do not intentionally teach bad habits.

      Why not change it to an actual useful task like mapping an array of values to an array of keys or something?

      Sure, it's a lot easier of a problem, but at least it makes sense and trains you how to do something that is useful.

      And there's still "insight" to gain...

  • Marecky Avatar

    Nice one, but I believe the description could use some improvements - specifically, I think it should be more specific about the argument names.

    There's no information indicating whether the argument names should be extracted from the value (as the usage example might imply) or fixed arg names should be used (as the test cases seem to indicate).

    I'm guessing the latter was the original intent, but seeing how most solutions focus on parsing the values, the description definitely is not clear enough in this regard.

  • hbakhtiyor Avatar

    Lack of test cases. Results of the solutions will be unexpected with below code.

    function f(a, //comment
    b,
    /*
    some comments
    */
    c){}
    
  • michacom Avatar

    Have I to preserve original parameters names?

  • wthit56 Avatar

    Nicely done. The "Assert" message is a little ambiguous. If you made it somehting along the lines of Assert: argumentMap['a1'] == 'a1value', that would be much more obvious what's going on. Out of interest, is there a reason you aren't using Test.assertEquals(result, expected, message)?

    • ohager Avatar

      Thanks for feedback. I considered your suggestion and applied it. There's no special reason why I chose 'expect'. IMHO the code sounds slightly more natural with test.expects() than with test.assertEquals().

      Suggestion marked resolved by ohager 11 years ago
  • FesterBesterTester Avatar

    The failure message for one of your test cases is "Assert: a1 = 1]". It should say "Assert: a1 === 1".

  • ferlio Avatar

    Cool, nice one!