Create a Doubly Linked List

this challenge not working properly. Can someone test it?

can you provide a link to that challenge?

Hmmm… I’m stumped. It worked for me.

Are you using Chrome browser? Did you change the name of any of the provided variables?

Maybe post your code and someone will see a bug.

var Node = function(data, prev) { = data;
  this.prev = prev; = null;
var DoublyLinkedList = function() {
  this.head = null;
  this.tail = null;

  this.add =function(element){
    // var newest = new Node(element,null)
      var temp = this.tail
      var newest = new Node(element,this.tail)
      newest.prev = this.tail; = newest;
      this.tail = newest;
      this.head = new Node(element,null)
      this.tail = this.head;
  this.remove = function(element){
            this.head =

          this.tail = this.tail.prev
      var node = this.head;
      var prev=node.prev;
      var next =





      return null;

  // change code below this line
  // change code above this line

var test = new DoublyLinkedList();


remove function refuses to work. Also i cant preview how code is working because JSON.stringify() wont convert this structure into a string, so can only guess where to seek the problem

You have minor bugs in the two edge cases removing head or removing tail

  1. The new head or new tail will need some housekeeping on next / prev
  2. After removing head or tail your while loop also executes

OK - I have taken a closer look at this challenge. (OK, really I took a nap and came back)

My “passing” solution does not satisfy this requirement below. So I think that there is a flaw in the testing software - that should have been caught.

while the remove method should remove all occurrences of a given element in the list.

So I guess the below should not be an issue but rather a requirement.

  1. After removing head or tail your while loop also executes