I have written this code which is exactly what it is asking for, still not able to pass

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function Queue() {
var collection = [];
this.print = function() {
  console.log(collection);
};
// Only change code below this line
this.enqueue = function(insertElement){
  return collection.unshift(insertElement)
}
this.dequeue = function()
{
  return collection.shift()
}
this.front = function()
{
  return collection[0]
}
this.size = function()
{
  return collection.length
}
this.isEmpty = function()
{
  if(collection.length ==0)
  {
    return true
  }
  else{
    return false
  }
}
// Only change code above this line
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36

Challenge: Create a Queue Class

Link to the challenge:

Looks like the Queue might be showing and removing from the queue, the last inserted element, instead of the first inserted.

1 Like

Read the definition of enqueue again. The explanation pretty much tells you which method to use.

1 Like

Thank you for your help. I had thought of deleting very moment I put. I understood my mistake after I posted ,sorry for asking this question. Could not delete because it was restricting to , saying me to contact admin to delete post.
Again thank you very much for your help.

No need to apologize. I’m glad you figured it out on your own.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.