Created
April 7, 2021 22:21
-
-
Save RomanTurner/4aecb1415548ac0c40fdc80b28a48fef to your computer and use it in GitHub Desktop.
Push in a LL for a Stack
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
//Push data in the stack | |
push = (el) => { | |
//Create a new node | |
let node = new Node(el), | |
current; | |
//Add the new node at the top | |
current = this.head; | |
node.next = current; | |
this.head = node; | |
this.length++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment