// Doubly Linked lists

/*
Difference between a doubly linked list and a normal Linked list is that
we now have a double link: one for the next element and one for the previous
one.
*/

function DoublyLinkedList(){
  function Node(element){
    this.element = element;
    this.next = null;
    this.prev = null;
  }

  var head = null,
      tail = null,
      length = 0;
  
}

@@ -367,13 +367,886 @@
 th = 0;%0A
+%0A
   
+this.insert(element, position)%7B%0A    if (position %3E= 0 && position %3C= length)%7B%0A      var node = new Node(element),%0A          current = head,%0A          previous,%0A          index = 0;%0A%0A      if (position === 0)%7B%0A        if (!head) %7B%0A          head = node;%0A          tail = node;%0A        %7D else %7B%0A          node.next = current;%0A          current.prev = node;%0A          head = node;%0A        %7D%0A      %7D else if (position === length) %7B%0A          current = tail;%0A          current.next = node;%0A          node.prev = current;%0A          tail = node;%0A      %7D else %7B%0A        while (index++ %3C position)%7B%0A          previous = current;%0A          current = current.next;%0A        %7D%0A        node.next = current;%0A        previous.next = node;%0A%0A        current.prev = node;%0A        node.prev = previous;%0A      %7D%0A      length++;%0A      return true;%0A    %7D else %7B%0A      return false;%0A    %7D%0A  %7D;%0A%0A%0A
 %0A%7D%0A

add insert method for doubly linked list