# Possible solution to Create a Doubly Linked List

Continuing the discussion from freeCodeCamp Challenge Guide: Create a Doubly Linked List:

Really had a good time solving this challenge .

Solution
``````var Node = function(data, prev) {
this.data = data;
this.prev = prev;
this.next = null;
};
this.tail = null;

if(!data){
return false; //return if no data
}
let newNode = new Node(data, null);
}else{
while(nextNode.next){
nextNode = nextNode.next;
}
nextNode.next = newNode;
}
//create a reference for previous node to the newly added node
if(this.tail == null){
this.tail = newNode;
}else{
let prevNode = this.tail;
this.tail = newNode;
this.tail.prev = prevNode
}
};

//Remove method
this.remove = (ele)=>{
//if no head and tail => empty
return null;
}
//if element at the end -> remove and update .next to null
if(this.tail.data == ele){
let prevNode = this.tail.prev;
this.tail = prevNode;
this.tail.next = null;
return;
}
//loop over the nodes till the final node, find the node, reference the next node to the previous node and update the node with proper .prev
while(current.next){
if(current.data == ele){
let removedNode = current;
let prevNode = current.prev;
let nextNode = current.next;