Build a Festival Crowd Flow Simulator - Step 12

Tell us what’s happening:

The error message says that i should use the modulo operator, I thought i did. What am i doing wrong ?

Your code so far

const morningGates = [
  { id: "North", capacity: 5, queue: [3, 6, 2, 4] },
  { id: "East", capacity: 3, queue: [2, 4, 3, 5] },
  { id: "South", capacity: 4, queue: [1, 2, 3, 1] },
  { id: "West", capacity: 2, queue: [4, 1, 2, 3] },
];

const nightGates = [
  { id: "North", capacity: 4, queue: [6, 2, 5, 1] },
  { id: "East", capacity: 2, queue: [3, 3, 4, 2] },
  { id: "South", capacity: 5, queue: [2, 1, 2, 3] },
  { id: "West", capacity: 3, queue: [5, 2, 1, 4] },
];

function initializeThroughput(gates) {
  const summary = {};
  for (const gate of gates) {
    summary[gate.id] = 0;
  };
  return summary;
}

function processGateFlow(gate, tickIndex) {
  let currentTickQueue = gate.queue[tickIndex];
  let processed = 0;
  while (currentTickQueue > 0 && processed < gate.capacity) {
    currentTickQueue--;
    processed++;
  }
  return {
    processed: processed,
    overflow: currentTickQueue
  };
}

function rerouteOverflow(gates, currentGate, tickIndex, overflowAmount) {
  const currentIndex = gates.indexOf(currentGate);

// User Editable Region

const nextGateIndex = (currentIndex + 1 ) % gates.length;
gates[nextGateIndex].queue[tickIndex] += overflowAmount;
console.log(overflowAmount + " attendees rerouted to " + gates[nextGateIndex].id);

}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.4 Safari/605.1.15

Challenge Information:

Build a Festival Crowd Flow Simulator - Step 12

Github Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-festival-crowd-flow-simulator/69bac027df64d4433c708d44.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @dreyes61

You are asked to add a new variable, and nothing else.

Try removing the two lines of code below the variable declaration.

Happy coding