Priority queue test broken

bug in test?

Your code so far


function PriorityQueue () {
this.collection = [];
this.printCollection = function() {
  console.log(this.collection);
};
// Only change code below this line
this.enqueue=(x)=>{
  if(this.isEmpty()){
    this.collection.push(x)
  } else {
    let added=false;
    for(var i=0;i<this.size();i++){
      if(x[1]>this.collection[i][1]){
        this.collection.splice(i,0,x)
        added=true;
        break;
      }
    }
    if(!added){
      this.collection.push(x)
    }
  }
}
this.dequeue=()=>{
  let value=this.collection.shift()
  return value
}
this.size=()=>this.collection.length
 this.isEmpty=()=>!this.size()?true:false

// Only change code above this line
}

let que=new PriorityQueue()
que.enqueue(['cat',2])
que.enqueue(['person',5])
console.log(que.size())
console.log(que.isEmpty())
que.enqueue(['mouse',1])
que.enqueue(['dog',3])
que.printCollection()
console.log(que.dequeue())
que.printCollection()

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Challenge: Create a Priority Queue Class

Link to the challenge:

The condition is:
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.
so number 1 has the highest priority. You can adjust your if statement:

if(x[1]<this.collection[i][1])

In addition
Your que.dequeue() returns with priority. However, the dequeue should return only the current item, not its priority.
So simply change

this.dequeue=()=>{
  let value=this.collection.shift()
  return value[0]
}

Good work