回答編集履歴
5
テキスト追加
answer
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
一案としまして、以下のようにすると合計を得ることができます。
|
|
4
4
|
```javascript
|
|
5
|
-
const
|
|
5
|
+
const sum = $(".en").get().reduce((s, e) => +e.value + s, 0);
|
|
6
6
|
```
|
|
7
7
|
- **動作確認用サンプル: **[https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011](https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011)
|
4
テキスト追加
answer
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
一案としまして、以下のようにすると合計を得ることができます。
|
|
4
4
|
```javascript
|
|
5
|
-
$("#begin").on("click", function(){
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const total = $(".en").get().reduce((s, e) => +e.value + s, 0);
|
|
8
|
-
|
|
9
|
-
console.log(total);
|
|
10
|
-
});
|
|
11
6
|
```
|
|
12
7
|
- **動作確認用サンプル: **[https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011](https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011)
|
3
テキスト追加
answer
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
```javascript
|
|
5
5
|
$("#begin").on("click", function(){
|
|
6
6
|
|
|
7
|
-
const total = $(".en").get().reduce((
|
|
7
|
+
const total = $(".en").get().reduce((s, e) => +e.value + s, 0);
|
|
8
8
|
|
|
9
9
|
console.log(total);
|
|
10
10
|
});
|
2
テキスト追加
answer
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
こんにちは
|
|
2
2
|
|
|
3
|
-
一案としまして、
|
|
3
|
+
一案としまして、以下のようにすると合計を得ることができます。
|
|
4
4
|
```javascript
|
|
5
5
|
$("#begin").on("click", function(){
|
|
6
6
|
|
1
テキスト追加
answer
CHANGED
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
```javascript
|
|
5
5
|
$("#begin").on("click", function(){
|
|
6
6
|
|
|
7
|
-
const total = $(".en")
|
|
7
|
+
const total = $(".en").get().reduce((sum, elm) => +elm.value + sum, 0);
|
|
8
|
-
.get()
|
|
9
|
-
.map(elm => +elm.value)
|
|
10
|
-
.reduce((sum, amount) => sum + amount);
|
|
11
8
|
|
|
12
9
|
console.log(total);
|
|
13
10
|
});
|
|
14
11
|
```
|
|
15
|
-
- **動作確認用サンプル: **[https://codepen.io/jun68ykt/pen/
|
|
12
|
+
- **動作確認用サンプル: **[https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011](https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011)
|