"Create a Priority Queue Class" test appears wrong

Tell us what’s happening:
I run the following code as a solution to this challenge and it appears to work fine. But the result says:

The priority queue should return items with a higher priority before items with a lower priority and return items in first-in-first-out order otherwise.

But it appears to do just this.

I embedded debug code, which you can see, and this shows the actions and before and after. The only problem I see here is that somehow after populating the initial collection with “David Brown” the array acquires the last 3 entries. Curiously it never actually adds these entries in the remainder of the test despite recording the actions of adding them.

When I try all this independent of the test environment it works as described. Assuming, of course that by higher priority you mean a lower priority number, which isn’t really explicit. (in any case changing this makes no difference)

Your code so far


function PriorityQueue () {
    this.collection = [];
    this.printCollection = function() {
      console.log(this.collection);
    };
    // Only change code below this line
    this.enqueue = function(value) {
        var idx = this.collection.findIndex(x => x[1] > value[1])
        idx = idx == -1 ? this.collection.length : idx;
        this.collection.splice(idx,0,value);
        console.log("in", value);
        this.printCollection();
    }
    this.dequeue = function() {
        console.log("out", this.collection[0]);
        this.printCollection();
        return this.collection.splice(0,1);
    }
    this.size = function() {
        return this.collection.length;
    }
    this.front = function() {
        return this.collection[0];
    }
    this.isEmpty = function() {
        return this.collection.length == 0;
    }
    // Only change code above this line
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:65.0) Gecko/20100101 Firefox/65.0.

Link to the challenge:
data-structures/create-a-priority-queue-class