Untitled

Run Settings
LanguageJavaScript
Language Version
Run Command
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; } prepend(value) { const oldNode = { value: value, next:null } oldNode.next = this.head; this.head = oldNode; this.length++; return this; } } let myLinkedList = new LinkedList(10); myLinkedList.append(5); myLinkedList.append(16); myLinkedList.prepend(1); console.log(myLinkedList);
Editor Settings
Theme
Key bindings
Full width
Lines