insertBefore(value, newValue) {
    let newNode = new Node(newValue);
    let current = this.head;
    if (!this.head) {
      this.head = newNode;
      this.tail = newNode;
      this.length++;
      return;
    } else if (this.head.data === value) {
      this.insert(newValue);
      return;
    } else {
      while (current.next !== null) {
        if (current.next.data === value) {
          newNode.next = current.next;
          current.next = newNode;
          this.length++;
          return;
        }
        current = current.next;
      }
    }
    throw new Error('Node not found');
  }
// add a new node with the given newValue immediately before the first value node
add a new node with the given newValue immediately before the first value node
add a new node with the given newValue immediately before the first value node
insertBefore(value, newValue) {
    let newNode = new Node(newValue);
    let current = this.head;
    if (!this.head) {
      this.head = newNode;
      this.tail = newNode;
      this.length++;
      return;
    } else if (this.head.data === value) {
      this.insert(newValue);
      return;
    } else {
      while (current.next !== null) {
        if (current.next.data === value) {
          newNode.next = current.next;
          current.next = newNode;
          this.length++;
          return;
        }
        current = current.next;
      }
    }
    throw new Error('Node not found');
  }
insertBefore ( value , newValue ) { let newNode = new Node ( newValue ) ; let current = this . head ; if ( ! this . head ) { this . head = newNode ; this . tail = newNode ; this . length ++ ; return ; } else if ( this . head . data === value ) { this . insert ( newValue ) ; return ; } else { while ( current . next !== null ) { if ( current . next . data === value ) { newNode . next = current . next ; current . next = newNode ; this . length ++ ; return ; } current = current . next ; } } throw new Error ( 'Node not found' ) ; }
add a new node with the given newValue immediately before the first value node
add a new node with the given newValue immediately before the first value node