text: const ListNode = require('../extensions/list-node');
  /**
   * 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
   *
   */
  
  class Queue {
    constructor() {
      this.head = null; // the last node
      this.tail = null; // the first node
      this.length = 0;
    }
  
    get size() {
      return this.tail;
    }
  
    enqueue(element) {
      const node = new ListNode(element);
      if (this.head) {
        this.tail.next = node; // add new node to the end
        this.tail = node; // upd the last node
      } else {
        this.head = node;
        this.tail = node;
      }
      this.length++;
    }
  
    dequeue() {
      const current = this.head;
      this.head = this.head.next;
      this.length--;
      return current.value;
    }
  }
  
  module.exports = Queue;
  