Skip to content

Commit 7d30195

Browse files
committed
fix: insertAt insertion at the end of the list issue
1 parent 4700d74 commit 7d30195

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

linked_list/list.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ class LinkedList {
130130

131131
if (index === 0) {
132132
this.prepend(node);
133+
return;
133134
}
134135

135-
if (index === this.size - 1) {
136+
if (index === this.size) {
136137
this.append(node);
138+
return;
137139
}
138140

139141
let currentNode = this.head;

0 commit comments

Comments
 (0)