Retired

JavaScript Built in Types: Arrays, Strings, Sets (retired)

Description
Loading description...
  • Please sign in or sign up to leave a comment.
  • JohanWiltink Avatar

    Why the unused, confusing functionality ( delimeter ) in the example solution?

    This is a 7 kyu kata; beginners might look up your solution to see how it should canonically be done, it should be as clean, simple and efficient as you can make it.

    • JavaScripts Avatar

      That's the idea. It gets you thinking about how you might possibly extend the functionality into something better while maintaining backwards compatability. It's food for thought essentially.

    • JohanWiltink Avatar

      Or it just confuses the H3ll out of 7 kyu solvers who don't yet even know what default arguments are, but can convert between strings, arrays, and sets.

      I remain unconvinced, but it's your kata.

    • JavaScripts Avatar

      Eh you've sold me. I'll take it out.

  • JohanWiltink Avatar

    99 more random tests wouldn't hurt.

    Using the same input for six assertions at a time would mean you only need two reference solutions ( generate a string, calculate the corresponding array and set, use those values as inputs and expected outputs ).

    The it-headers of the random tests could show values in a nicer way. Use JSON.stringify for strings and arrays, and maybe mock up something custom to replicate the output of console.log(set)?

    Use strictEqual for strings.

    args is just a wrapper for Array.from. Also, it's just unnecessary if you pass a single string instead of a list of chars.

  • JohanWiltink Avatar

    Extending prototypes should be done with Object.defineProperty, otherwise, you'll have enumerable properties on your prototype, which will give unexpected results with for .. in.

    The kata sould specify, and test for, non-enumerability.

    • JavaScripts Avatar

      Thats a good point. Do you think I should change it in the initial solution as well or let people figure it out on their own?

    • JohanWiltink Avatar

      The rest of the kata isn't difficult enough to make people figure it out on their own, I think.

      Giving it to them for free is most useful if you explain why it's necessary though.

    • JavaScripts Avatar

      Okay. I added parts to the description, solution, and tests related to nonenumerability. I also threw in at least 99 random tests.

      Issue marked resolved by JavaScripts 7 months ago