Why am I getting errors?

Tell us what’s happening:

Your code so far


function PriorityQueue() {
this.collection = [];
this.printCollection = function () {
console.log(this.collection);
};
this.enqueue = function (newitem) {
if (this.isEmpty()) {
return this.collection.push(newitem);
}
this.collection = this.collection.reverse();
var found_index = this.collection.findIndex(function (item){
return newitem[1] >= item[1];
});
if (found_index === -1) {
his.collection.push(newitem);
} else {
this.collection.splice(found_index, 0, newitem);
}
this.collection = this.collection.reverse();
};
this.dequeue = function () {
if (!this.isEmpty()) {
return this.collection.shift()[0];
} else {
return "The queue is empty.";
}
};
this.size = function () {
return this.collection.length;
};
this.front = function () {
return this.collection[0][0];
};
this.isEmpty = function () {
return this.size() > 0 ? false : true;
};
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0.

Challenge: Create a Priority Queue Class

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.