Skip to content

Commit 3097ad5

Browse files
committed
- export statement implementation.
- minor updates in comments.
1 parent 0a497f1 commit 3097ad5

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

example-2.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
import {cleanConsole, createAll} from './data';
22
const companies = createAll();
33

4-
const f2 = (companies, hasCar) => {
5-
return companies.map((company) => {
6-
const users = company.users.filter((u) => {
7-
return (u.car === hasCar);
8-
});
9-
10-
return {
11-
...company,
12-
users,
13-
usersLength: users.length,
14-
};
15-
});
4+
export default function f2(companies, hasCar) {
5+
return companies.map(
6+
(company) => {
7+
const users = company.users.filter(
8+
(u) => (u.car === hasCar),
9+
);
10+
11+
return {
12+
...company,
13+
users,
14+
usersLength: users.length,
15+
};
16+
});
1617
};
1718

1819
cleanConsole(2, companies);
19-
console.log('---- EXAMPLE 2 --- ', f2(companies, false));
20-
21-
// -----------------------------------------------------------------------------
22-
// INSTRUCCIONES EN ESPAÑOL
23-
24-
// Crear una función tomando como parámetro la variable "companies" y el
25-
// booleano "hasCar". Para cada "company" debe conservar solo
26-
// "users" cuyo valor de atributo "car" es igual al parámetro del
27-
// función "hasCar" y el atributo "usersLength" deben indicar el total de
28-
// "users" correspondientes al parámetro "hasCar".
20+
console.log('---- EXAMPLE 2 --- ', f2(companies, true));
2921

3022
// -----------------------------------------------------------------------------
3123
// INSTRUCTIONS IN ENGLISH
@@ -36,6 +28,15 @@ console.log('---- EXAMPLE 2 --- ', f2(companies, false));
3628
// "hasCar" function and the "usersLength" attribute must indicate the number of
3729
// "users" corresponding to the "hasCar" parameter.
3830

31+
// -----------------------------------------------------------------------------
32+
// INSTRUCCIONES EN ESPAÑOL
33+
34+
// Crear una función tomando como parámetro la variable "companies" y el
35+
// booleano "hasCar". Para cada "company" debe conservar solo
36+
// "users" cuyo valor de atributo "car" es igual al parámetro del
37+
// función "hasCar" y el atributo "usersLength" deben indicar el total de
38+
// "users" correspondientes al parámetro "hasCar".
39+
3940
// -----------------------------------------------------------------------------
4041
// INSTRUCTIONS EN FRANÇAIS
4142

0 commit comments

Comments
 (0)