7 kyu

Array.prototype.reverse()

2,671 of 2,690wthit56
Description
Loading description...
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • Cloud Walker Avatar

    Interesting kata.

  • lichiy Avatar

    The tests of this kata don't take into account empty array elements. E.g. let arr = [0,1,2,,,5]; // [0, 1, 2, empty, empty, 5] arr.reverse(); // [5, empty, empty, 2, 1, 0]

    With a simple exchange of values, we will get the value undefined instead of empty elements: arr.reverse(); // [5, undefined, undefined, 2, 1, 0]

  • Disembow Avatar

    Please cure the tests, "assertSimilar is deprecated, use assertDeepEquals"

  • 1savage1 Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    CoffeeScript translation Kumited! Please accept :D

  • jecho7 Avatar

    This comment has been hidden.

  • ORCatalin Avatar

    Even if it is working correctly and i return the same array (this) the fourth test it logs "Original array should be returned." Can someone give me a hint?

  • piecedigital Avatar

    I noticed that in my solution I can log the variable "Test" and get a number (2) back if reverse method was called. However for the fourth test it logs the number BUT wants the original array. Can someone please help me see what I'm missing here? I don't understand why a reverse method would be called just to not be reversed.

  • ndugger Avatar

    This comment has been hidden.

  • fighterleslie Avatar

    This is a good kata!

  • computerguy103 Avatar

    This comment has been hidden.

  • florinsander Avatar

    I'm not sure if I'm mistaken, but you're saying original array should be returned when called without reverse, yet you expect to be reversed in place. The protoype I wrote does not modify in place, if you want the original array.. Either something is wrong or I'm reading it the wrong way.

  • krispykim Avatar

    Can you put some sample test cases?

  • mortonfox Avatar

    I am getting the following error: Max Buffer reached: Too much information has been written to stdout.

    This happens even when I'm not using console.log to add anything to the output. So my solution won't validate.

  • mvovchak Avatar

    This comment has been hidden.

  • dlz Avatar

    You might want to test odd-length arrays, should someone come up with an algorithm that would choke on them. I don't know, maybe it's not such a big issue.

  • user3482173 Avatar

    IT is not clear that we should return this and not a copy, wich would be the more intuitive reasoning.

  • surtich Avatar

    I think you need to clarify if the returned object is the this object or a copy of it.