add(n, index) {
    if (index > this.length || index < 0) {
      throw new Error('Index out of bounds');
    }

    const node = new Node(n);

    if (index !== undefined && index < this.length) {
      let prevNode;
      let nextNode;

      if (index === 0) {
        // Insert in the beginning
        nextNode = this.head;
        this.head = node;
      } else {
        nextNode = this.getNode(index);
        prevNode = nextNode.prev;
        prevNode.next = node;
        node.prev = prevNode;
      }
      nextNode.prev = node;
      node.next = nextNode;
    } else {
      // Insert at the end
      if (!this.head) this.head = node;

      if (this.tail) {
        this.tail.next = node;
        node.prev = this.tail;
      }
      this.tail = node;
    }

    this._length++;
  }
Adds the element to the end of the list or to the desired index

@param { Object } n
@param { Number } index