Create a Circular Queue - Help

Tell us what’s happening:
I am unable to go further with this exercise. Looking for a help.

Your code so far


class CircularQueue {
  constructor(size) {
    this.queue = [];
    this.read = 0;
    this.write = 0;
    this.max = size - 1;

    while (size > 0) {
      this.queue.push(null);
      size--;
    }
  }
  print() {
    return this.queue;
  }

  enqueue(item) {

    if (this.queue[this.write] == null) {
      this.queue[this.write] == item;
      this.write++;
      this.write %= this.queue.length;
      console.log(this.write);
      return item;
    }
    return null;
    // Only change code above this line
  }

  dequeue() {
    // Only change code below this line
    let removedItem = null;
    if (this.queue[this.read] !== null) {
      removedItem = this.queue[this.read];
      this.queue[this.read] = null;
      this.read++;
      this.read %= this.queue.length;
    }
    return removedItem;
  }
  // 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/70.0.3538.110 Safari/537.36.

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

So your biggest issue is in your enqueue. When you are adding the item to this.queue[this.write], you are using the comparator equals: == rather than the assignment equals: =.

Try that on, let us know.

Thank you @snowmonkey . It worked out.
I realized how important going through every line of the code is, with this challenge. I had spent a lot of time on this challenge to bring out the logic, but with a small typo, I didn’t get my solution to pass through.