Ad
  • Custom User Avatar

    yeah, since the Array technically is iterable as well; might wait for more opinions for that matter before adding the actual check though

  • Custom User Avatar
  • Custom User Avatar

    🤦 that was embarassing. thanks for your help :)

  • Custom User Avatar

    Your current unshift() function will actually move the existing values by the length of the original list list.length, not the amount of added by unshift elements elements.length; since the filter fixed tests are using the list after unshift tests and other, it'd be broken.

  • Custom User Avatar

    there should be a check that List is iterable. although it may invalidate many solutions, i think it would make the kata much more interesting

  • Custom User Avatar

    the initial code should be a class, to keep up with the times

  • Custom User Avatar

    can you check the Ensuring the original list is not changed test ? I am fairly certain that my filter implementation is pure, but i get list[3] has been modified: expected 10 to equal 2. it seems as though this test is actually checking the original list against the filtered one

  • Custom User Avatar

    The fun part is, Array.prototype.functionName = undefined won't work because the other third-party components will definitely use it (chai or describe/it, for example), thus throwing an error; Array.prototype.functionName = function() {} sometimes works as intended, but sometimes it'll throw Response received but no data was written to STDOUT or STDERR.. (shift function will not throw that, but the tests won't be actually checked, although the describe/it sections' titles will be shown normally without any details XD )

  • Custom User Avatar

    Reworked the tests so that the error messages should be more concise now.

  • Custom User Avatar
    Expected: 5, instead got: undefined
    Expected: 8, instead got: undefined
    Expected: 9, instead got: undefined
    

    The error messages are completely useless.

  • Custom User Avatar

    Double the satisfaction. Once with some good coding practice, and a second time seeing the creative ways used to cheat 😋

  • Custom User Avatar

    Yes, my solution follows the task literally. But since title is to implement the List and there are descriptions of what methods should do still I think solution should work as if no Array existed at all. We can not remove it totally, but we can develop test criterias which will check if this requirement is fulfilled. For example, remove all methods from Array prototype and as you said check return types of methods.

    But maybe I'm just not satisfied with Kata's complexity and digging to deep. :) Then again if we follow the rules literally, .filter() should work exactly as Array's one does, thus return an Array.

  • Custom User Avatar

    Pfff... who knows? ^^

  • Custom User Avatar

    You're returning an object with a length property, values on numerical keys, and method getters pointing to Array methods.

    It's as close to an array as you'll come, but it's an object which is not an array. It's legal. It's not a cheat.

    It may feel like a cheat, but because after all everything is an object, how are you going to distinguish a too simple one from a sufficiently complicated one, and where do you draw the line?

    I have no better solution.

    Edit: Hmm .. .filter() doesn't return a List; it returns an Array. (More solutions are guilty of this.) Would that be a fair requirement? (It's not explicitly specified.)

  • Custom User Avatar

    Why the downvote? What did I do wrong? If I don't know, I can't fix it.

    (Aimed at downvoter, not necessarily at OP.)

  • Loading more items...