title: How to iterate through a linked list in javascript
body: <p>Someone shared this beautifully elegant way to create a linked list from an array.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function removeKFromList(l, k) {
    let list = l.reduceRight((value, next)=&gt;({next, value}), null);
    console.log(list);
  }
  
  let l = [3, 1, 2, 3, 4, 5];
  let k = 3;
  
  removeKFromList(l, k);</code></pre>
  </div>
  </div>
  </p>
  
  <p>It's pretty easy to iterate arrays (for, filter, map, reduce, etc.) but a linked list has none of those features. I need to iterate through to remove k values from the list. I'm guessing I need to create a variable for the current node and use a while loop, but there's no documentation on this. I've seen some repl code doing it but it seems unnecessarily complicated. </p>
  
  <p>How do you iterate through a linked list in javascript?</p>