"The first item should be removable from the list." it is but I am unable to pass the test

Tell us what’s happening:

As the title says I have console.loged and I can surely remove the first element that is head and tail both are null . But can’t pass the test . Please help.

Your code so far


var Node = function(data, prev) {
this.data = data;
this.prev = prev;
this.next = null;
};
var DoublyLinkedList = function() {
this.head = null;
this.tail = null;
// Only change code below this line
this.add = function(item){
  var newNode = new Node(item)
  if(!this.head){
    this.head = newNode;
    this.tail = newNode;  
  } else {
    newNode.prev = this.tail;
    this.tail.next = newNode;
    this.tail = newNode;
  }
  }

this.remove = function() {
  if(this.head === null){
    return null;
  } else {
    const prev = this.tail.prev;
    if(prev != null){
      prev.next = null;
      this.tail = prev;
    } else { //prev = null means only one node in list
      this.head = null;
      this.tail = null;
    }
  }
}
// Only change code above this line
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0.

Challenge: Create a Doubly Linked List

Link to the challenge: