Ad
  • Default User Avatar

    In case you're getting a message like Got b,c,a,d,e. Expected array values = b,c,a,d,e, it's probably because you're using splice, which returns an ARRAY.

  • 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

    Got the working solution but it won't let me pass... I tested myself many times and my function wokrs well.

    "Got a,b,c,d,e. Expected array values = c,a,b,d,e"

    I think something is wrong here...

  • Custom User Avatar

    I agree. It's horrible to have a method that can return either a string or an array depending on circumstances.

    Returning an unmodified array or throwing would be better.

  • 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

    assgin, you meant assign.

  • Default User Avatar

    Hmmmm. Got b,c,a,d,e. Expected array values = b,c,a,d,e

    Something I'm missing?

  • 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

    You are given [] an empty array and floor 1. The hotel is empty, so floor 1 is empty. I am not sure how you populated the hotel with those names.

  • Custom User Avatar

    don't know what to do with the first basic question
    not correct [], 1 given - Expected: [], instead got: ["foo","bar","foobar","barfoo","foofoo","barbar"]

    why fun(arr, 1) should return an empty array?

    I passed all the test cases, only failed at this one.

    anyone?

  • Custom User Avatar

    That's true. I didn't search for similar task before I publish.
    thx for your feedback

  • Custom User Avatar

    There are already an abundance of already-approved prime number katas in JavaScript:

    I don't feel that this adds anything to the existing katas.

    Sorry!

  • 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.

  • Default User Avatar

    This issue is now resolved (I forgot to mark it as such before posting my previous reply).

    Feel free to mark any of these comments as having spoiler content. I'm on the fence about it: on one hand, they may contain helpful information for others; on the other hand, it may be a bit too much information.

  • Loading more items...