Ad
  • Custom User Avatar

    Nice Solution !!

    I liike it.

  • Custom User Avatar

    Ok, thanks for the feedback !

    Kata is already retired ^^

    Yes, I will read the authoring text intensively.

    Cheers

  • Custom User Avatar

    Hi,

    • no random tests
    • chai must be used to write the tests, instead of the outdated homemade framework
    • most likely already done before (at the very least, "nothing new")
    • the output should stay consistent (typewise) => empty string should return 0, not false

    If you are interested in authoring kata, you should read the docs before your next try (this one probably won't survive the beta phase).

    Cheers

  • Custom User Avatar

    That was just my first idea and try, so I don't take it too hard ;)

    Furthermore I could learn something about how the beta phase works and trained writing some markdown.

    Thank you for your effort to guide me a little bit, that was impressive !!

    peace out ;)

  • Custom User Avatar

    I see you have a test for it, but I also see it doesn't appear to be working. ( I can't submit a solution anymore, so I can't showcase a wrong solution passing the tests ).

    Again, the point is moot, so it's not much use to try to fix whatever is broken. But it seems broken. The new testing got insufficient testing before publication. You could have tested this by assigning functions to the prototype - that should have failed, and it doesn't.

  • Custom User Avatar

    ( Yes, this is moot, because the kata has been retired )

    Unfortunately, that makes String.prototype.map identical to Array.prototype.map, so it makes the kata less interesting ( one can simply return Array.prototype.map.call(this,callback) ). The same goes for reduce(Left|Right) I think. So only filter requires actual logic, and it's limited to a join(""). This may ( partially ) be why people are so unsatisfied with the kata ( though lacking implementation certainly didn't help ).

    Additionally, I forgot that the Array.prototype methods have an optional argument for an alternative this context to the callback - that should have been tested as well.

    I don't think it's worth it to try to resurrect the kata. I appreciate your point of enabling for String what can be done with Array, but JS itself already has usable facilities for doing it ( I have been doing it for years without the additional plumbing you made into this kata ).

    Side note: I have always been amazed by the speed of Array.from(string) - internals may have been optimised for exactly this use case.

  • Default User Avatar

    I'm not sure about this one. It's a lot of repeating yourself and I didn't enjoy it that much. But that's just my opinion.

  • Custom User Avatar

    I specified that the callback function of map should be polymorphic and return an array

  • Custom User Avatar

    I specified that the prototype extensions are not enumerable and added a test for that property

  • Custom User Avatar

    Note: filter can return a string. reduce does not have a problem, because it just collapses the string ( just an iterable really ) to a single value and is thus inherently polymorphic in its callback function and initial value. but map should really return an array ( or other iterable of arbitrary elements ), because the callback function might not return characters. or you should specify that its callback function must be monomorphically Char -> Char instead of polymorphically Char -> a, which it can be for arrays ( actually (Char,Int,String) -> Char of course ).

  • Custom User Avatar

    Totally right !!

    I will get to that right away.

    Thank you !

  • Custom User Avatar

    If you want solvers to extend prototypes, require it to be done correctly. Prototype extensions should not be enumerable, this should be specified, and tested.

    ETA: Note that I have ranked this kata as a 5, because if implemented correctly, it's not a 7. Extending prototypes is not for novices.

  • Custom User Avatar

    Ensure that the methods do work exactly like the Array implementations

    This is not tested completely; it is also specified incompletely.

    Array implementations return arrays. When called on String operands, they work (!), and return arrays ( for map and filter). If you want strings as a return value, this should be specified.

    The Array implementation callback functions accept not just an element, but also an index and the whole array. This is not tested ( and not explicitly specified, which would be a good thing ).

  • Custom User Avatar