-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-6.js
More file actions
executable file
·52 lines (41 loc) · 1.67 KB
/
example-6.js
File metadata and controls
executable file
·52 lines (41 loc) · 1.67 KB
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
49
50
51
52
import {cleanConsole, createAll} from './data';
const companies = createAll();
// -----------------------------------------------------------------------------
// INSTRUCTIONS IN ENGLISH
// Create a function taking the "companies" variable as a parameter and returning
// a new object whose attributes are the concatenation of the name, first name and
// the age of each user. Each attribute must have the value of boolean "car".
// See example below.
// -----------------------------------------------------------------------------
// INSTRUCCIONES EN ESPAÑOL
// Cree una función tomando la variable "companies" como parámetro y devolviendo
// un nuevo objeto cuyos atributos son la concatenación del apelido, nombre y
// edad de cada "user". Cada atributo debe tener el valor de boolean "car".
// Ver ejemplo a continuación.
// -----------------------------------------------------------------------------
// INSTRUCTIONS EN FRANÇAIS
// Créer une fonction prenant en paramètre la variable "companies" et renvoyant
// un nouve objet dont les attributs sont la concaténation du nom, du prénom et
// de l'âge de chaque "user". Chaque attribut devra avoir la valeur du booléen
// "car". Voir exemple ci-dessous.
const example = {
johnDoe32: true,
BernardoMinet45: false,
alinaChef23: true,
};
console.log(example);
export default function f6(cs) {
return cs.map(
(c) => (
c.users.reduce(
(accumulator, user) => ({
...accumulator,
[`${user.firstName}${user.lastName}${user.age}`]: user.car,
}),
{},
)
),
);
};
cleanConsole(6, companies);
console.log('---- EXAMPLE 6 --- ', f6(companies));