Quick actions

cmd+k|ctrl+k

Navigation

Languages

LinkedLists

Snippet info

Language

JavaScript

Visibility

public

Author

psleung94

Created

2020-08-01T21:09:34Z

Updated

2020-08-01T21:36:34Z

class LinkedList
{
    constructor(value)
    {
        this.head = {
            value: value,
            next: null
        }
        this.tail = this.head;
        this.length = 1;
    }
    append(value)
    {
        const newNode = {
            value: value,
            next: null
        }
        this.tail.next = newNode;
        this.tail = newNode;
        this.length++;
        return this;
    }
    
}
const linkedlist = new LinkedList(10);
linkedlist.append(5);
console.log(linkedlist);

INFO