From 5105898aa7e2ed4c770ec58434c00f4b76539580 Mon Sep 17 00:00:00 2001 From: seIncorp <34153549+seIncorp@users.noreply.github.com> Date: Mon, 30 Jul 2018 14:33:17 +0200 Subject: [PATCH] Twice defined (#124) * Twice defined Parameter 'deletedTail' were defined twice. * Update LinkedList.js * Update LinkedList.js --- src/data-structures/linked-list/LinkedList.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/data-structures/linked-list/LinkedList.js b/src/data-structures/linked-list/LinkedList.js index 0176b6bf..4d6b9e26 100644 --- a/src/data-structures/linked-list/LinkedList.js +++ b/src/data-structures/linked-list/LinkedList.js @@ -127,18 +127,14 @@ export default class LinkedList { * @return {LinkedListNode} */ deleteTail() { + const deletedTail = this.tail; if (this.head === this.tail) { // There is only one node in linked list. - const deletedTail = this.tail; this.head = null; this.tail = null; return deletedTail; } - - // If there are many nodes in linked list... - const deletedTail = this.tail; - // Rewind to the last node and delete "next" link for the node before the last one. let currentNode = this.head; while (currentNode.next) {