Hướng dẫn thử thách
1 / 33
Step 1
In this workshop, you will use JavaScript to simulate the flow of attendees at a music festival.
You will work with two datasets that describe the festival gates during morning and night shifts:
```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] },
];
```
Each gate object contains the following properties:
- `id`: A string that identifies the gate.
- `capacity`: The number of attendees the gate can process per tick.
- `queue`: An array of numbers representing how many attendees arrive at the gate during a specific tick.
To begin, create an empty function named `initializeThroughput` with a parameter `gates`.
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.js
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵