-
Notifications
You must be signed in to change notification settings - Fork 1
/
Coding Meetup #6 - Higher-Order Functions Series - Can they code in the same language.js
32 lines (28 loc) · 1.76 KB
/
Coding Meetup #6 - Higher-Order Functions Series - Can they code in the same language.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
// You will be given an array of objects (associative arrays in PHP, tables in COBOL) representing data about developers who have signed up to attend the next coding meetup that you are organising.
// Your task is to return either:
// true if all developers in the list code in the same language; or
// false otherwise.
// For example, given the following input array:
// var list1 = [
// { firstName: 'Daniel', lastName: 'J.', country: 'Aruba', continent: 'Americas', age: 42, language: 'JavaScript' },
// { firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 22, language: 'JavaScript' },
// { firstName: 'Hanna', lastName: 'L.', country: 'Hungary', continent: 'Europe', age: 65, language: 'JavaScript' },
// ];
function isSameLanguage(list) {
// thank you for checking out the Coding Meetup kata :)
let l = list.map(e=>e.language)
return l.every( v => v === l[0] )
}
var list1 = [
{ firstName: 'Daniel', lastName: 'J.', country: 'Aruba', continent: 'Americas', age: 42, language: 'JavaScript' },
{ firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 22, language: 'JavaScript' },
{ firstName: 'Hanna', lastName: 'L.', country: 'Hungary', continent: 'Europe', age: 65, language: 'JavaScript' },
];
var list2 = [
{ firstName: 'Mariami', lastName: 'G.', country: 'Georgia', continent: 'Europe', age: 29, language: 'Python' },
{ firstName: 'Mia', lastName: 'H.', country: 'Germany', continent: 'Europe', age: 39, language: 'Ruby' },
{ firstName: 'Maria', lastName: 'I.', country: 'Greece', continent: 'Europe', age: 32, language: 'C' },
];
console.log(isSameLanguage(list1), true)
console.log(isSameLanguage(list2), false)
// isSameLanguage(list1)