Skip to content

Instantly share code, notes, and snippets.

@RomanTurner
Created April 7, 2021 22:22
Show Gist options
  • Save RomanTurner/88b9417f7b9f7979b90ccc326c33fef7 to your computer and use it in GitHub Desktop.
Save RomanTurner/88b9417f7b9f7979b90ccc326c33fef7 to your computer and use it in GitHub Desktop.
Pop on LL for Stack
//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