Why does the output of the stack have undefined

the js code is as follows:

    function Stack(){
        let items = [];
        // 
        this.push = function(element) {
            items.push(element);
        }
        this.pop = function(){
            return items.pop();
        }
        // 
        this.peek = function(){
            return items[items.length-1];
        }
        this.isEmpty = function(){
            return items.length == 0;
        }
        this.size = function(){
            return items.length;
        }
        this.clear = function(){
            items = [];
        }
        this.print = function(){
            console.log(items.toString());
        }
    }
    
    let st = new Stack();
    console.log(st.isEmpty());
    st.push(1);
    st.push(2);
    st.push(3);
    console.log(st.peek());
    console.log(st.isEmpty());
    console.log(st.print());
    st.pop();
    console.log(st.print());

the output result is
true
3
false
1
undefined
1
undefined

Mar.03,2021

your print has already been printed inside, why print it again on the outside? Is it questionable that the


print method does not return a value?

Menu