Skip to content

Commit b51a6f5

Browse files
committedApr 18, 2019
Improve examples
1 parent fcd80e3 commit b51a6f5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
 

‎JavaScript/1-extract-metadata/1-filter-simple.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const names = [
1414
'Muammar Muhammad Abu Minyar al-Gaddafi',
1515
'Rene Descartes',
1616
'Fyodor Mikhailovich Dostoyevsky',
17-
'Benedito de Espinosa'
17+
'Benedito de Espinosa',
1818
];
1919

2020
// Filter mixed with conditions
@@ -41,4 +41,6 @@ const filter = names => {
4141

4242
// Usage
4343

44-
console.dir(filter(names));
44+
const result = filter(names);
45+
console.dir({ names });
46+
console.dir({ result });

‎JavaScript/1-extract-metadata/2-metaprogramming.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const names = [
1414
'Muammar Muhammad Abu Minyar al-Gaddafi',
1515
'Rene Descartes',
1616
'Fyodor Mikhailovich Dostoyevsky',
17-
'Benedito de Espinosa'
17+
'Benedito de Espinosa',
1818
];
1919

2020
// Metadata
@@ -44,15 +44,17 @@ const filter = (names, conditions) => {
4444
return valid;
4545
};
4646
Object.assign(operations, {
47-
length: (s, v) => s.length >= v[0] && s.length <= v[1],
47+
length: (s, v) => s.length >= v[0] && s.length <= v[1],
4848
contains: (s, v) => s.includes(v),
49-
starts: (s, v) => s.startsWith(v),
50-
ends: (s, v) => s.endsWith(v),
51-
not: (s, v) => !check(s, v)
49+
starts: (s, v) => s.startsWith(v),
50+
ends: (s, v) => s.endsWith(v),
51+
not: (s, v) => !check(s, v),
5252
});
5353
return names.filter(s => check(s, conditions));
5454
};
5555

5656
// Usage
5757

58-
console.dir(filter(names, conditions));
58+
const result = filter(names, conditions);
59+
console.dir({ names });
60+
console.dir({ result });

0 commit comments

Comments
 (0)
Please sign in to comment.