-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoding-meetup-13.js
More file actions
24 lines (22 loc) · 796 Bytes
/
Copy pathcoding-meetup-13.js
File metadata and controls
24 lines (22 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Coding Meetup #13 - Is the Meetup Language Diverse? kata
https://www.codewars.com/kata/58381907f8ac48ae070000de
*/
// function isLanguageDiverse(list) {
// const languages = list.reduce((languages, person) => {
// languages[person.language] += 1;
// return languages;
// }, {Python: 0, JavaScript: 0, Ruby: 0})
// const counts = Object.values(languages);
// return Math.max(...counts) / Math.min(...counts) <= 2;
// }
function isLanguageDiverse(list) {
return list.reduce((languages, person, index) => {
languages[person.language] += 1;
if (index !== list.length -1 ) {
return languages;
} else {
const counts = Object.values(languages);
return Math.max(...counts) / Math.min(...counts) <= 2;
}
}, {Python: 0, JavaScript: 0, Ruby: 0})
}