I just read that blog about linked list and tried to do that then I got an output but that output is not match with the blog author. I need some help
class ListNode {
constructor(data) {
this.data = data;
this.next = null;
}
}
class LinkList {
constructor(head = null) {
this.head = head;
}
}
// putting all together
let node1 = new ListNode(2);
let node2 = new ListNode(5);
// console.log(node1);
node1.next = node2;
// let's create a linklist with node1
let list = new LinkList(node1);
console.log(list.head.data); //output-: 2 but expected 5