Ad
  • Default User Avatar

    Wow, some comments are three/four years old, and you did not process them? Anyway, I updated the description fixing several typos and grammar issues. Still this kata should not be approved if no effort is made to:

    • provide example tests
    • provide random tests

    Also, returning "no target" is really not in line with best practice that return values should be of the same type (except for null or undefined). A function that sometimes returns an array and sometimes a string is badly designed. I would suggest to review this behaviour.

  • Custom User Avatar

    Could do with example tests, e.g. those from the description.

  • Custom User Avatar

    It's super unclear that your supposed to return a new array. And if you don't do it, you get a very poor error about undefined having no length property.

    • Add some initial test cases. I hate when I have to create my own tests since you have no access to submit tests.
    • Have the user modify the array "in place", which makes much more sense for a prototype method.
      OR
    • Change it to a static method on array. That makes more sense if you're supposed to return a new array.
      OR
    • Make it clearer in instructions that you have to return a new array, and add an first test that checks an array is return (which is not the same pointer than the prototype array).
  • Custom User Avatar
    • I don't like kata giving bad habbits to developers. A function that doesn't return always the same kind of element is one bad habit.
      I would prefer for example, that instead of returning 'no target' it returns either the array unchanged or an empty array. In this case it's always returning an array.
    • It is not clearly specificed that the new prototype function must return a new array, and NOT modifie the existing one (like splice can do).
    • Typo: you assgin doesn't -> you assign doesn't
  • Custom User Avatar

    A nice concept; well done. There was a typo in the description: you should aware should be you should be aware of, or something like that.

    You can use Test.assertSimilar(result, expected, message) to test things like objects or arrays. This will also print out a "got... expected..." message in addition to whatever message you add to it. This will also avoid running the .move() twice.

    If you wanted, you could randomise the order of the tests, by sticking in the inputs in an array, and using Test.randomize(array) to reorder them; then loop over them and test the inputs. This will make it harder to cheat the tests. And if you want to go the whole hog, you can randomly generate tests, too.