Solución
solution.tsTypeScript
export function testStack(a: number, b: number): number | undefined {
// Implementa createStack con closure y úsalo aquí
function createStack() {
// Array privado aquí
const arr = []
return {
push(value: number) {return arr.push(value)},
pop(): number | undefined { return arr.pop(); },
size(): number { return arr.length; },
};
}
const stack = createStack();
stack.push(a);
stack.push(b);
return stack.pop();
}
0respuestas