Complete the code to update the tail pointer after deleting the last node.
this.tail = this.tail[1];After deleting the last node, the tail should point to the previous node.
Complete the code to remove the last node's reference to the list.
if (this.tail) this.tail.next = [1];
After deletion, the new tail's next pointer should be null to mark the end.
Fix the error in the condition that checks if the list is empty after deletion.
if (this.tail === [1]) this.head = null;
If tail is null, the list is empty, so head should also be null.
Fill both blanks to correctly update pointers when deleting the last node.
if (this.tail) { this.tail.next = [1]; this.tail = this.tail[2]; }
The new tail's next pointer should be null, and tail moves to its previous node.
Fill all three blanks to complete the delete from end method correctly.
deleteFromEnd() {
if (!this.tail) return null;
const removed = this.tail;
if (this.tail === this.head) {
this.head = [1];
this.tail = [2];
} else {
this.tail = this.tail[3];
if (this.tail) this.tail.next = null;
}
return removed;
}If the list has one node, both head and tail become null after deletion. Otherwise, tail moves to previous node.
