title: How to console.log LinkedList
body: <p>I'm looking at a tutorial to solve how to reverse a linked list.</p>
  <p>I want to <code>console.log</code> through the solution to see how everything works but I get the following</p>
  <pre><code>error: Uncaught TypeError: Cannot read property 'next' of undefined
  </code></pre>
  <p>What am I doing wrong?</p>
  <pre><code>var reverseList = function(head) {
    let prevNode = null
    while (head !== null) {
      let nextNode = head.next;
      head.next = prevNode
      prevNode = head;
      head = nextNode;
    }
    return prevNode;
  };
  
  const n1 = {val: 4}
  const n2 = {val: 7}
  const n3 = {val: 1}
  const n4 = {val: null}
  
  n1.next = n2;
  n2.next = n3;
  n3.next = n4;
  
  reverseList(n1)
  </code></pre>