Alternative pop()

Try to solve Learn Data Structures: Create a Stack Class |

I know the answer can be simple as return collection.pop(), but I want to try alternative method. cl=collection.length I don’t know why the pop method can’t pass the test

this.pop = function(){
    if (cl===0){
      return undefined
    }else if(cl > 0){
      let popelement = collection[cl-1]
      collection[cl-1] = undefined
      return popelement

you have not removed the element with that, the last element has just become undefined
as in, from [1,2,3,4] to [1,2,3,undefined], it has to become [1,2,3]