// your code goes here
class Node{
constructor(value){
this.value = value;
this.next = null;
}
}
class LinkedList {
constructor(value){
const newNode = new Node(value);
this.head = newNode;
this.tail = this.head;
this.length = 1;
console.log('constructor:', newNode);
}
push(value){
const newNode = new Node(value);
console.log(newNode);
console.log(this.head);
if (!this.head) {
console.log('no nodes');
this.head = newNode;
this.tail = newNode;
}else{
this.tail.next = newNode;
this.tail = newNode;
}
this.length++;
console.log(this.head);
return this;
}
}
let newLinkedList = new LinkedList();
newLinkedList.push(5);
console.log(newLinkedList);