Created
April 7, 2021 22:22
-
-
Save RomanTurner/88b9417f7b9f7979b90ccc326c33fef7 to your computer and use it in GitHub Desktop.
Pop on LL for Stack
This file contains hidden or 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
//Pop the item from the stack | |
pop = () => { | |
let current = this.head; | |
//If there is item then remove it | |
//and make the next element as the first | |
if(current){ | |
let el = current.element; | |
current = current.next; | |
this.head = current; | |
this.length--; | |
return el; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment