Hackerrank: "Cut the sticks" Javascript solution
Once the array is sorted, as you have it, the crux of this algorithm is simply:

subtract the smallest element from every element, then remove elements that equal 0

With es6 and method chaining, this can be expressed in a single line of code.  The rest is just the boilerplate and a condition to check when the recursion is finished -- all similar to what you have now.

Here's the rewrite:

function main() {
  readLine();
  const input = readLine().split(' ').map(Number).sort((a,b) =&gt; a-b );
  cut(input);

  function cut(arr) {
    if (!arr.length) return;
    console.log(arr.length);
    cut(arr.map(x =&gt; x - arr[0]).filter(x =&gt; x &gt; 0)); // &lt;-- the essence of the algorithm
  }
}


I should also point out that the above, as well as your solution, runs in \$O(n^2)\$.  You can in fact do better: \$O(n\log n)\$.  Because after the array is sorted, you can solve the problem with a single pass through the array, as follows:

function main() {
  readLine();
  const input = readLine().split(' ').map(Number).sort((a,b) =&gt; a-b );
  cut(input, input[0]);

  function cut(arr, min) {
    if (!arr.length) return;
    console.log(arr.length);
    while(arr[0] == min) arr.shift();
    cut(arr, arr[0]);
  }
}


Here we're taking advantage of the fact that after each cut, the elements that are removed are precisely those equal to the minimum element.  And to produce the output required for the problem, we notice that we don't actually have to do the cuts for every element of the list.  We merely have to remove the elements of 0 length.