We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22e073d commit a0e195dCopy full SHA for a0e195d
linkedList.js
@@ -23,11 +23,20 @@ LinkedList.prototype.addToTail = function(value) {
23
this.tail = newNode;
24
}
25
26
-let myLL = new LinkedList();
+LinkedList.prototype.removeHead = function() {
27
+ if(!this.head) return null;
28
+ let val = this.head.value;
29
+ this.head = this.head.next;
30
+ if(this.head) this.head.prev = null;
31
+ else this.tail = null;
32
+ return val;
33
+}
34
+
35
+let ll = new LinkedList();
36
-myLL.addToTail(10);
-myLL.addToTail(20);
-myLL.addToTail(30);
-myLL.addToHead(100);
37
+ll.addToHead(1000);
38
+ll.addToHead(2000);
39
+ll.addToTail(3000);
40
-console.log(myLL.tail.prev.prev.prev);
41
+ll.removeHead();
42
+console.log(ll.removeHead());
0 commit comments