Implement a Stack - Implement a Stack

Tell us what’s happening:

pop function is working but test 6 is not passing, can anyone help on this?

Your code so far

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

function push(stack, element) {
  stack.collection.push(element)
}

function pop(stack) {
  const topEl = stack.collection.pop()
  if (topEl || !topEl && stack.collection.length > 0) return topEl
  return undefined;
}

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

function isEmpty(stack) {
  if (stack.collection.length == 0) {
    return true
  } else {
    return false
  }
}

function clear(stack) {
  stack.collection = []
}

Your browser information:

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

Challenge Information:

Implement a Stack - Implement a Stack

try testing your pop function.
for eg what would it give if you tested it when the stack only has one element and that element is 0?