---
id: 69bac047282614c7ef87d370
title: Step 14
challengeType: 1
dashedName: step-14
---

# --description--

To help track how attendees move through the system, log the following message to the console: `overflowAmount + " attendees rerouted to " + gates[nextGateIndex].id`. You can use either string concatenation or template literals.

# --hints--

Your `rerouteOverflow` function should log the following message to the console `overflowAmount + " attendees rerouted to " + gates[nextGateIndex].id`.

```js
const testGates = [
  { 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 spy = __helpers.spyOn(console, "log");

try {
  const northGate = testGates[0];
  rerouteOverflow(testGates, northGate, 0, 5);
  
  const expectedCall = ["5 attendees rerouted to East"];
  
  assert.deepEqual(
    spy.calls[0],
    expectedCall,
    "rerouteOverflow should log the overflow amount and next gate's id"
  );

} catch (err) {
  assert.fail(err);
} finally {
  spy.restore();
}
```

# --seed--

## --seed-contents--

```js
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);
  const nextGateIndex = (currentIndex + 1) % gates.length;
  gates[nextGateIndex].queue[tickIndex] += overflowAmount;
--fcc-editable-region--

--fcc-editable-region--
}
```
