title: JavaScript: Traversing and Reversing Singly-Linked Lists and Converting Between SLLs and Numbers
body: <p><strong>INTRO</strong>
  Today, while doing a mock interview with a Facebook JavaScript problem, I blanked out on how to handle singly-linked lists.  The code I had so far is simply a function that takes 2 linked lists and returns another linked list.  My plan is below.</p>
  
  <p><strong>QUESTION</strong>
  You are given two non-empty linked lists of arbitrary length representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.</p>
  
  <p>You may assume the two numbers do not contain any leading zero, except the number 0 itself.</p>
  
  <p><em>Example:</em></p>
  
  <blockquote>
    <p>Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 Explanation:
    342 + 465 = 807.</p>
  </blockquote>
  
  <p><strong>PLAN</strong></p>
  
  <ol>
  <li>Copy each number from the first linked list into an array in order.</li>
  <li>Reverse the array.</li>
  <li>Convert the array to a string then to an integer and store this in a variable.</li>
  <li>Repeat this for the second linked list.</li>
  <li>Sum the two numbers and store this value in a variable.</li>
  <li>Convert this sum into a string.</li>
  <li>Use Array.from on this string to convert it into an array then reverse the array.</li>
  <li>?</li>
  <li>Return the new linked list.</li>
  </ol>
  
  <pre><code>/*
   * Definition for singly-linked list.
   * function ListNode(val)
   * {
   *  this.val = val;
   *  this.next = null;
   * }
   */
  
  /* Expected input and output.
   * @param {ListNode} l1
   * @param {ListNode} l2
   * @return {ListNode}
   */
  
  var addTwoNumbers = function(l1, l2)
  {
  
  };
  
  </code></pre>