Create a Stack Class - failing peek and pop

Tell us what’s happening:
Why am I failing my peek and pop test? for the pop case I literally used Array.pop() and it still failed;

Your code so far


function Stack() { 
    var collection = [];
    this.print = function() {
        console.log(collection);
    };
    // Only change code below this line
    this.peek = function(){
        var temp = collection.pop();
        collection.push(temp);
        return temp;
    }
    this.push = function(){

    }
    this.pop = function(){
        console.log(collection);
        var temp = collection.pop();
        console.log(collection);
        return temp;
    }
    this.isEmpty = function(){
        if(collection.length == 0){
            return true;
        }
        return false;
    }
    this.clear = function(){
        collection = [];
    }
    // Only change code above this line
}

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/data-structures/create-a-stack-class

this.peek = function(){
        var temp = collection.pop();

If you’re peeking, you can’t mutate the collection. Though I see you are pushing it back. Though I thought the purpose of this challenge was to not use push, pop, and others like that. Instead, you would manually manage that array through the use of indexes.

Aside from my previous comment, you should also flesh out your push method. It should help you pass the tests.