MCPcopy Index your code
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / peek

Method peek

stacks/queue-via-stacks.js:30–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28 return this.stackOldest.pop();
29 }
30 peek() {
31 this.#shiftStacks(); // Ensure stackOldest has the current elements
32 return this.stackOldest.peek();
33 }
34 empty() {
35 return this.stackNewest.size() + this.stackOldest.size() === 0;
36 }

Callers

nothing calls this directly

Calls 2

#shiftStacksMethod · 0.95
peekMethod · 0.45

Tested by

no test coverage detected