Skip to content

Commit b2084cc

Browse files
committed
Changed_explanation_for_Array#map_method
1 parent 84dec4f commit b2084cc

File tree

1 file changed

+8
-5
lines changed
  • docs/2-browser-apps/04-anonymous-function

1 file changed

+8
-5
lines changed

docs/2-browser-apps/04-anonymous-function/index.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@ const add3 = function (a, b) {
8383
このように、他の関数の引数として呼び出される関数のことを<Term type="callbackFunction" strong>コールバック関数</Term>と呼びます。
8484

8585
```javascript
86-
const rates = [3, 5, 1];
87-
const stars = rates.map((rate) => {
88-
return "".repeat(rate);
89-
});
90-
document.write(stars); // ★★★,★★★★★,★
86+
function doubleArray(arr) {
87+
return arr.map((value) => value * 2);
88+
}
89+
90+
const originalArray = [1, 2, 3, 4, 5];
91+
const doubledArray = doubleArray(originalArray);
92+
93+
document.write(doubledArray); // [2, 4, 6, 8, 10]
9194
```
9295

9396
:::tip プリミティブ値のラッパーオブジェクト

0 commit comments

Comments
 (0)