Skip to content

Instantly share code, notes, and snippets.

@sibnerian
Created February 17, 2019 22:18
Show Gist options
  • Save sibnerian/9f5ac90b42c6da0c973a902cab69afa2 to your computer and use it in GitHub Desktop.
Save sibnerian/9f5ac90b42c6da0c973a902cab69afa2 to your computer and use it in GitHub Desktop.
class LinkedList {
constructor() {
this.head = null;
this.tail = null;
}
add(value) {
const node = { value };
if (this.tail != null) {
this.tail.next = node;
this.tail = node;
} else {
this.head = node;
this.tail = node;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment