What is the longer code for the pop function in Javascript?

Our teacher asks us what is the longer code for the pop function. These are his examples for shift and push: this.shift = function() { if (this.rootNode != undefined) { thisrootNode.right; this.length--; } else { console.log("stack is already empty"); } } this.push = function(num) { ... show more Our teacher asks us what is the longer code for the pop function.

These are his examples for shift and push:

this.shift = function() {
if (this.rootNode != undefined) {
thisrootNode.right; this.length--;
} else {
console.log("stack is already empty");
}
}

this.push = function(num) {
let currentNode = this.rootNode;
while(currentNode.right != undefined) {
currentNode = currentNode.right;
}
currentNode.right = new Node(num);
}
1 answer 1