Skip to content

Commit 5105898

Browse files
seIncorptrekhleb
authored andcommitted
Twice defined (trekhleb#124)
* Twice defined Parameter 'deletedTail' were defined twice. * Update LinkedList.js * Update LinkedList.js
1 parent 6e897a0 commit 5105898

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,14 @@ export default class LinkedList {
127127
* @return {LinkedListNode}
128128
*/
129129
deleteTail() {
130+
const deletedTail = this.tail;
130131
if (this.head === this.tail) {
131132
// There is only one node in linked list.
132-
const deletedTail = this.tail;
133133
this.head = null;
134134
this.tail = null;
135135

136136
return deletedTail;
137137
}
138-
139-
// If there are many nodes in linked list...
140-
const deletedTail = this.tail;
141-
142138
// Rewind to the last node and delete "next" link for the node before the last one.
143139
let currentNode = this.head;
144140
while (currentNode.next) {

0 commit comments

Comments
 (0)