Tell us what’s happening:
Hi, my test is not passing tests 2 and 4 already. It’s also failing test 6, which i don’t understand at all - how should pop return falsy values? It either returns undefined or the popped element as it is…?
Maybe i’m not understanding how the lab itself should be implemented…? The functions i wrote look pretty simple so far and they work. I read there was a bug almost 2 months ago, is it still bugged maybe?
Your code so far
function initStack() {
return {
collection: []
};
}
function push(element,stack) {
stack.collection.push(element);
}
function pop(stack) {
if (stack.collection.length === 0) {
return undefined;
}
return stack.collection.pop();
}
console.log(pop({ "collection": [1,2,3,4,5] })); // 5
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0
Challenge Information:
Implement a Stack - Implement a Stack