Created
February 17, 2019 22:18
-
-
Save sibnerian/9f5ac90b42c6da0c973a902cab69afa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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