Write a program to reverse a linked list.
function reverse(head) {
let node = head,
previous,
tmp;
while (node) {
// save next before we overwrite node.next!
tmp = node.next;
node.next = previous;
previous = node;
node = tmp;
}
return previous;
}
BY Best Interview Question ON 17 Dec 2019