Complete the code to initialize the previous pointer to null.
let prev = [1];We start with prev as null because initially there is no previous node.
Complete the code to store the next node before changing links.
let next = [1].next;We save current.next in next to not lose the rest of the list before reversing the link.
Fix the error in reversing the link by assigning the previous node to current's next.
[1].next = prev;We reverse the link by pointing current.next to prev.
Fill both blanks to update pointers for the next iteration.
prev = [1]; current = [2];
After reversing the link, move prev to current and current to next to continue.
Fill all three blanks to complete the iterative reverse function.
function reverseList(head) {
let prev = [1];
let current = head;
while (current !== null) {
let next = current.[2];
current.[3] = prev;
prev = current;
current = next;
}
return prev;
}Initialize prev to null. Save current.next in next. Reverse link by setting current.next = prev.
