MCPcopy Create free account
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / peek

Method peek

stacks/triple-stack.js:42–50  ·  view source on GitHub ↗
(stack)

Source from the content-addressed store, hash-verified

40 }
41
42 peek(stack) {
43 let length = this._getLength(stack),
44 value;
45 if (length > 0) {
46 let idx = (length - 1) * 3 + stack - 1;
47 value = this._array[idx];
48 }
49 return value;
50 }
51
52 isEmpty(stack) {
53 return this._getLength(stack) === 0;

Callers

nothing calls this directly

Calls 1

_getLengthMethod · 0.95

Tested by

no test coverage detected