The highest priority is: 2. I have two items with the highest priority:
0: (2) [“animal”, 2] and 3: (2) [“rabbit”, 2]
The last is 3: (2) [“rabbit”, 2] and the priorityQueue.front() returns “rabbit”.
This return value is fails on the last test… What have to send return if not “rabbit”?
If need I will provide the full code, but maybe I have only the problem of interpretation.
class PriorityQueue {
... my full code is here...
}
const priorityQueue = new PriorityQueue;
priorityQueue.printCollection(); // []
console.log(priorityQueue.dequeue()); // undefined
console.log(priorityQueue.isEmpty()); // true
priorityQueue.enqueue(["human", 1]);
priorityQueue.enqueue(["ufo", 0]);
priorityQueue.enqueue(["rabbit", 2]);
priorityQueue.enqueue(["ufo2", 0]);
priorityQueue.enqueue(["ufo3", 0]);
priorityQueue.enqueue(["animal", 2]);
priorityQueue.printCollection(); // my above test array
console.log(priorityQueue.front()); // rabbit
after the row of above commands what have to give back the “console.log(priorityQueue.front());”?
Thank you very much indeed for your help… At least I found the issue. From the array have to delete the first element, not the last. I changed the pop() method, and now I pass the test
Thanks.
P.s: Once I pass a test I always go to see other solutions on the forum to check different solutions and take some idea how to resolve problems on other way… The solution of guide is very difficult. I tried to understood the logic, but at least I gave up…