質問編集履歴
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,6 +112,70 @@
|
|
112
112
|
|
113
113
|
```
|
114
114
|
|
115
|
+
|
116
|
+
|
117
|
+
###試したこと
|
118
|
+
|
119
|
+
```html
|
120
|
+
|
121
|
+
//パターン1
|
122
|
+
|
123
|
+
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; }
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//パターン2
|
128
|
+
|
129
|
+
NaN
|
130
|
+
|
131
|
+
```
|
132
|
+
|
133
|
+
```js
|
134
|
+
|
135
|
+
//パターン1:innerHTML = calcFn;にした場合。
|
136
|
+
|
137
|
+
btn.addEventListener('click', (event) => {
|
138
|
+
|
139
|
+
event.preventDefault();
|
140
|
+
|
141
|
+
if (array.length === 10) {
|
142
|
+
|
143
|
+
alert('ok');
|
144
|
+
|
145
|
+
document.getElementById('text').innerHTML = calcFn;
|
146
|
+
|
147
|
+
} else {
|
148
|
+
|
149
|
+
alert('全て選択してください');
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
});
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
//パターン2:innerHTML = calcFn();にした場合。
|
158
|
+
|
159
|
+
btn.addEventListener('click', (event) => {
|
160
|
+
|
161
|
+
event.preventDefault();
|
162
|
+
|
163
|
+
if (array.length === 10) {
|
164
|
+
|
165
|
+
alert('ok');
|
166
|
+
|
167
|
+
document.getElementById('text').innerHTML = calcFn();
|
168
|
+
|
169
|
+
} else {
|
170
|
+
|
171
|
+
alert('全て選択してください');
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
```
|
178
|
+
|
115
179
|
### 補足情報(FW/ツールのバージョンなど)
|
116
180
|
|
117
181
|
|