text: const { NotImplementedError } = require("../extensions/index.js");
  
  const { ListNode } = require("../extensions/list-node.js");
  
  /**
   * Implement the Queue with a given interface via linked list (use ListNode extension above).
   *
   * @example
   * const queue = new Queue();
   *
   * queue.enqueue(1); // adds the element to the queue
   * queue.enqueue(3); // adds the element to the queue
   * queue.dequeue(); // returns the top element from queue and deletes it, returns 1
   * queue.getUnderlyingList() // returns { value: 3, next: null }
   */
  module.exports = class Queue {
    head = null;
    tail = null;
    getUnderlyingList() {
      // throw new NotImplementedError("Not implemented");
      // remove line with error and write your code here
      return this.head;
    }
  
    enqueue(value) {
      //throw new NotImplementedError('Not implemented');
      // remove line with error and write your code here
      if (this.tail !== null) {
        const node = new ListNode(value);
        node.next = null;
        this.tail.next = node;
        this.tail = node;
      } else {
        const node = new ListNode(value);
        node.next = null;
        this.head = node;
        this.tail = node;
      }
    }
  
    dequeue() {
      //throw new NotImplementedError('Not implemented');
      // remove line with error and write your code here
      if (this.head !== null) {
        const val = this.head.value;
        this.head = this.head.next;
  
        return val;
      }
    }
  };
  