Create a Priority Queue Class issue

Hi, i’m trying the “Data Structures: Create a Priority Queue Class” challenge, but I have an issue. I passed all the tests apart from the last one - "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."

I did some tests with and it looks like it works fine, but it doesn’t pass the FCC test.
Can someone help me finding the problem?

My code so far


function PriorityQueue () {
    this.collection = [];
    this.printCollection = function() {
      console.log(this.collection);
    };
    // Only change code below this line
    this.enqueue = function(item) {
        if(!this.collection.length) {
           return this.collection.push(item)
        }else {
      for (let i=this.collection.length-1; i>=0; i--) {
          if(item[1] >= this.collection[i][1]) {
             return this.collection.splice(i+1,0, item)
              i=0
          } 
      } 
      if (item[1] < this.collection[0][1])  {
              return this.collection.unshift(item)
          }
        }
    };

        this.dequeue = function() {
      return this.collection.shift()
    };

            this.size = function() {
      return this.collection.length
    };

                this.front = function() {
      return this.collection[0]
    };

                    this.isEmpty = function() {
      return !this.collection.length
    };
    // Only change code above this line
}

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/data-structures/create-a-priority-queue-class/

The code you wrote worked when I tested it in chrome, but it doesn’t pass the test