We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e1a35f commit 620b8b7Copy full SHA for 620b8b7
README.md
@@ -69,3 +69,27 @@ console.log(getSalutation(10)); // Good Morning
69
```
70
71
<a href="https://codepen.io/Bunlong/pen/mjwWeY" target="_blank">Edit on Codepen</a>
72
+
73
+## Higher Order Functions
74
75
+A function that accepts another function as a parameter, or returns another function.
76
77
+For example:
78
79
+```javascript
80
+function mapConsecutive(values, fn) {
81
+ let result = [];
82
83
+ for(let i=0; i < values.length -1; i++) {
84
+ result.push(fn(values[i], values[i+1]));
85
+ }
86
87
+ return result;
88
+}
89
90
+const letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
91
+let twoByTwo = mapConsecutive(letters, (x, y) => [x, y]);
92
+console.log(twoByTwo); // [[a, b], [b, c], [c, d], [d, e], [e, f], [f, g]]
93
+```
94
95
+<a href="https://codepen.io/Bunlong/pen/JBJWRa" target="_blank">Edit on Codepen</a>
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments