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