Hacker News new | ask | show | jobs
by sturob 4870 days ago

  LinkedList.prototype.reverse = function () {
    var tail = function(prev, current){
      if (current.next) {
        tail(current, current.next);
      } else {
        this.head = current;
      }
      current.next = prev;
    }.bind(this);
  
    tail(null, this.head);
  };