Skip to content

Commit e996b28

Browse files
committed
Minor style modifications.
1 parent 1a04c50 commit e996b28

1 file changed

Lines changed: 40 additions & 26 deletions

File tree

example-3.js

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,52 @@ const isCapitalized = (s) => (s.charAt(0) === s.charAt(0).toUpperCase());
88

99
const f3 = (companies, hasCar) => {
1010
return (
11-
companies.find((c) => {
12-
// Check company name
13-
if (!isCapitalized(c.name)) return true;
14-
15-
return (
16-
c.users.find((u) => {
17-
// Check first name
18-
if ((typeof u.firstName === 'string' || u.firstName instanceof String)
19-
&& !isCapitalized(u.firstName)) return true;
20-
21-
// Check last name
22-
if ((typeof u.lastName === 'string' || u.lastName instanceof String)
23-
&& !isCapitalized(u.lastName)) return true;
24-
25-
return false;
26-
}) !== undefined
27-
);
28-
}) === undefined
11+
companies.find(
12+
(company) => {
13+
// Check company name
14+
if (!isCapitalized(company.name)) return true;
15+
16+
return (
17+
company.users.find(
18+
(user) => {
19+
// Check first name
20+
if (
21+
(
22+
typeof user.firstName === 'string'
23+
|| user.firstName instanceof String
24+
)
25+
&& !isCapitalized(user.firstName)
26+
) return true;
27+
28+
// Check last name
29+
if (
30+
(
31+
typeof user.lastName === 'string'
32+
|| user.lastName instanceof String
33+
)
34+
&& !isCapitalized(user.lastName)
35+
) return true;
36+
37+
return false;
38+
},
39+
) !== undefined
40+
);
41+
},
42+
) === undefined
2943
);
3044
};
3145

3246
cleanConsole(3, companies);
3347
console.log('---- EXAMPLE 3 --- ', f3(companies), f3(f1(companies)));
3448

49+
// -----------------------------------------------------------------------------
50+
// INSTRUCTIONS IN ENGLISH
51+
52+
// Create a function taking the "companies" variable as a parameter and returning
53+
// a boolean validating that all the names of the companies and the attributes "firstName"
54+
// and "lastName" of "users" are capitalized. You must test the operation
55+
// of this function by importing the function created for "example-1.js".
56+
3557
// -----------------------------------------------------------------------------
3658
// INSTRUCCIONES EN ESPAÑOL
3759

@@ -41,14 +63,6 @@ console.log('---- EXAMPLE 3 --- ', f3(companies), f3(f1(companies)));
4163
// Debes probar la operación de esta función importando la función creada
4264
// en el "example-1.js".
4365

44-
// -----------------------------------------------------------------------------
45-
// INSTRUCTIONS IN ENGLISH
46-
47-
// Create a function taking the "companies" variable as a parameter and returning
48-
// a boolean validating that all the names of the companies and the attributes "firstName"
49-
// and "lastName" of "users" are capitalized. You must test the operation
50-
// of this function by importing the function created for "example-1.js".
51-
5266
// -----------------------------------------------------------------------------
5367
// INSTRUCTIONS EN FRANÇAIS
5468

0 commit comments

Comments
 (0)