-
Notifications
You must be signed in to change notification settings - Fork 0
/
7kyu-greetDevelopers.js
48 lines (37 loc) · 2.22 KB
/
7kyu-greetDevelopers.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
40
41
42
43
44
45
46
47
48
/*
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 an array where each object will have a new property 'greeting' with the following string value:
Hi < firstName here >, what do you like the most about < language here >?
For example, given the following input array:
var list1 = [
{ firstName: 'Sofia', lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java' },
{ firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: 'Python' },
{ firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby' }
];
your function should return the following array:
[
{ firstName: 'Sofia', lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java',
greeting: 'Hi Sofia, what do you like the most about Java?'
},
{ firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: 'Python',
greeting: 'Hi Lukas, what do you like the most about Python?'
},
{ firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby',
greeting: 'Hi Madison, what do you like the most about Ruby?'
}
];
Notes:
The order of the properties in the objects does not matter (except in COBOL).
The input array will always be valid and formatted as in the example above.
*/
//P: one input, an array containing a list of event attendees
//R: return an array, with a greeting property added for each attendee in the list saying "Hi $firstName, what do you like most about $language?"
//E: { firstName: 'Sofia', lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java',
//greeting: 'Hi Sofia, what do you like the most about Java?'
//},
//P: map through array and add a property for each with the greeting
const greetMe = attendee => `Hi ${attendee.firstName}, what do you like the most about ${attendee.language}?`
function greetDevelopers(list) {
list.forEach(attendee => attendee.greeting = greetMe(attendee));
return list
}