-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday05.js
39 lines (28 loc) · 1.29 KB
/
day05.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ./day05.js
/*
Challenge #5 - Voting Station Calculation
The election is looming, and the dutiful City of Codeville staff has finalized
most of the details, except for one thing: where will citizens vote? There are
hundreds of buildings in town, but there are very specific requirements for
what constitutes an acceptable voting station. With very little time to decide,
the city needs our help to sort through the building data.
Instructions
Complete the function chooseStations(stations) that takes in an array of possible
voting stations, and then only returns the names of the stations that are
appropriate.
Your function will receive an array of stations, where each station itself is an
array with a name, a capacity, and a venue type.
In order for a station to be deemed appropriate, it must have a capacity of at
least 20, and be a school or community centre.
*/
const chooseStations = (stations) => {
const filteredStations = stations.filter(station => station[1] >= 20 && (station[2] === 'school' || station[2] === 'community centre'))
.map(sta => sta[0]);
return filteredStations;
};
const stations = [
['Big Bear Donair', 10, 'restaurant'],
['Bright Lights Elementary', 50, 'school'],
['Moose Mountain Community Centre', 45, 'community centre']
];
console.log(chooseStations(stations));