質問編集履歴
1
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -55,6 +55,38 @@
|
|
55
55
|
return result;
|
56
56
|
};
|
57
57
|
```
|
58
|
+
|
59
|
+
###試したこと
|
60
|
+
```html
|
61
|
+
//パターン1
|
62
|
+
function calcFn() { let scoreA = array.filter((_, x) => [0, 1, 3, 4, 7].includes(x)); let scoreB = array.filter((_, x) => [2, 5, 6, 8, 9].includes(x)); const reducer = (accumulator, currentValue) => accumulator + currentValue; let arrayA = scoreA.reduce(reducer); let arrayB = scoreB.reduce(reducer); let result = scoreA - scoreB; return result; }
|
63
|
+
|
64
|
+
//パターン2
|
65
|
+
NaN
|
66
|
+
```
|
67
|
+
```js
|
68
|
+
//パターン1:innerHTML = calcFn;にした場合。
|
69
|
+
btn.addEventListener('click', (event) => {
|
70
|
+
event.preventDefault();
|
71
|
+
if (array.length === 10) {
|
72
|
+
alert('ok');
|
73
|
+
document.getElementById('text').innerHTML = calcFn;
|
74
|
+
} else {
|
75
|
+
alert('全て選択してください');
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
//パターン2:innerHTML = calcFn();にした場合。
|
80
|
+
btn.addEventListener('click', (event) => {
|
81
|
+
event.preventDefault();
|
82
|
+
if (array.length === 10) {
|
83
|
+
alert('ok');
|
84
|
+
document.getElementById('text').innerHTML = calcFn();
|
85
|
+
} else {
|
86
|
+
alert('全て選択してください');
|
87
|
+
}
|
88
|
+
});
|
89
|
+
```
|
58
90
|
### 補足情報(FW/ツールのバージョンなど)
|
59
91
|
|
60
92
|
ここにより詳細な情報を記載してください。
|