質問するログイン新規登録

回答編集履歴

5

テキスト追加

2020/04/25 22:50

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  一案としまして、以下のようにすると合計を得ることができます。
4
4
  ```javascript
5
- const total = $(".en").get().reduce((s, e) => +e.value + s, 0);
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

テキスト追加

2020/04/25 22:49

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -2,11 +2,6 @@
2
2
 
3
3
  一案としまして、以下のようにすると合計を得ることができます。
4
4
  ```javascript
5
- $("#begin").on("click", function(){
6
-
7
- const total = $(".en").get().reduce((s, e) => +e.value + s, 0);
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

テキスト追加

2020/04/25 22:38

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -4,7 +4,7 @@
4
4
  ```javascript
5
5
  $("#begin").on("click", function(){
6
6
 
7
- const total = $(".en").get().reduce((sum, elm) => +elm.value + sum, 0);
7
+ const total = $(".en").get().reduce((s, e) => +e.value + s, 0);
8
8
 
9
9
  console.log(total);
10
10
  });

2

テキスト追加

2020/04/25 22:26

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  こんにちは
2
2
 
3
- 一案としまして、こんな感じで合計を出せます。
3
+ 一案としまして、以下のようにすると合計を得ることができます。
4
4
  ```javascript
5
5
  $("#begin").on("click", function(){
6
6
 

1

テキスト追加

2020/04/25 16:37

投稿

jun68ykt
jun68ykt

スコア9058

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/wvKJVOv?editors=1111](https://codepen.io/jun68ykt/pen/wvKJVOv?editors=1111)
12
+ - **動作確認用サンプル: **[https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011](https://codepen.io/jun68ykt/pen/vYNmBGw?editors=1011)