Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/data_structures/linked_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,33 @@ class LinkedList {
node = node.next;
}
}

/**
* Displays the full linked list in the terminal when run.
* You can append this function to other functions for an easier to read display.
*/
display(){
var runner = this.head;
var str = ''
while(runner!=null){
str += runner.val + " "
runner = runner.next
}
return str
}

/**
* removeFront() takes the head off the node, but still prevserves all subsequent nodes. Effectively moves the head to the original head.next.
*/
removeFront(){
if(!this.head){
return null
}
this.head = this.head.next
return this.head
}
}


/**
* A linked list node
Expand Down