Advertisement
nikolayneykov

Untitled

Dec 16th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const arr = [1, 2, 3, 4, 5];
  2.  
  3. const toLinkedList = (arr) => arr.reduceRight((node, el) => ({ value: el, next: node }), null);
  4.  
  5. const linkedList = toLinkedList(arr);
  6.  
  7. console.log(linkedList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement