text: /**
   * Reverse a singly linked list.
   *
   * Hint:
   *  A linked list can be reversed either iteratively or recursively. Could you implement both?
   *
   * Definition for singly-linked list.
   *  function ListNode(val) {
   *	this.val = val;
   *	this.next = null;
   *  }
   *
   * @param {ListNode} head
   * @return {ListNode}
   */
  var reverseList = function(head) {
      return head ? reverse(head, null) : head;
  };
  
  var reverse = function (node, previous) {
      let newHead = node;
      
      // recursive call to the tail
      if (node.next) newHead = reverse(node.next, node);
      // reverse from tail
      node.next = previous;
      
      return newHead;
  }
  