Skip to content

Commit 97926b1

Browse files
committed
Add comments to Linked List code.
1 parent 5105898 commit 97926b1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/data-structures/linked-list/LinkedList.js

+4
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ export default class LinkedList {
128128
*/
129129
deleteTail() {
130130
const deletedTail = this.tail;
131+
131132
if (this.head === this.tail) {
132133
// There is only one node in linked list.
133134
this.head = null;
134135
this.tail = null;
135136

136137
return deletedTail;
137138
}
139+
140+
// If there are many nodes in linked list...
141+
138142
// Rewind to the last node and delete "next" link for the node before the last one.
139143
let currentNode = this.head;
140144
while (currentNode.next) {

0 commit comments

Comments
 (0)