Array.prototype.popintermediateconst stack = []
stack.push(1)
stack.push(2)
stack.pop() // β 2 (LIFO)
stack.pop() // β 1Use push() and pop() together to implement a last-in, first-out (LIFO) stack.
Arrays in JavaScript naturally model a stack (LIFO β last in, first out). push adds to the top; pop removes from the top. This is the classic stack-pop operation.
Challenge: Implement stackPop(stack) β a named stack-pop function that removes and returns the top element of the stack.
stackPop([1, 2, 3]) // β 3 (stack is now [1, 2])
stackPop([99]) // β 99 (stack is now [])