We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ad43ee7 commit 85288c1Copy full SHA for 85288c1
linked-list.js
@@ -87,11 +87,7 @@ class LinkedList {
87
return null;
88
}
89
if (this.head.value === value) {
90
- if (!this.head.next) {
91
- this.head = null;
92
- } else {
93
- this.head = this.head.next;
94
- }
+ this.head = this.head.next;
95
this.size--;
96
return value;
97
} else {
@@ -100,7 +96,8 @@ class LinkedList {
100
prev = prev.next;
101
102
98
if (prev.next) {
103
- prev.next = prev.next.next;
99
+ removedNode = prev.next;
+ prev.next = removedNode.next;
104
105
106
0 commit comments