Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 372 Bytes

pop.md

File metadata and controls

25 lines (20 loc) · 372 Bytes

Pop

class Node {
    constructor(data) {
        this.data = data
        this.next = null 
    }
}

class LinkedList {
    constructor(head) {
        this.head = head 
    }

    pop = () => {
        let current = this.head 

        while (current.next.next) {
            current = current.next 
        }
        current.next = current.next.next 
    }
}