Implement a Stack - Implement a Stack

Tell us what’s happening:

there is a bug in this lab. She tried all the solutions and none of them worked.

Your code so far

function initStack() {
  return [];
}

function push(stack, item) {
  stack.push(item);
}

function pop(stack) {
  return stack.pop();
}

function peek(stack) {
  return stack[stack.length - 1];
}

function isEmpty(stack) {
  return stack.length === 0;
}

function clear(stack) {
  stack.length = 0;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Implement a Stack - Implement a Stack

Welcome to the forum @KevinNabil!

You are correct. The bug has been reported and should be fixed soon.

Meanwhile, please change your initStack() function to:

function initStack() {
  return {
    collection: []
  };
}

and code based on that to pass the tests in this challenge.

Happy coding!