回答編集履歴

1

追記

2017/07/05 06:42

投稿

shi_ue
shi_ue

スコア4437

test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  let waypoint = document.getElementsByName('waypoints[]');
4
4
 
5
- ```の部分は、nodeListが返ります。
5
+ ```の部分は、HTMLCollectionが返ります。
6
6
 
7
7
  ですので、
8
8
 
@@ -10,4 +10,22 @@
10
10
 
11
11
  let waypts = [{location: waypoint, stopover: true}];
12
12
 
13
+ ```はおかしいですね。HTMLCollectionはforEachメソッドがないので、
14
+
15
+ `[].forEach.call`(`Array.prototype.forEach.call`と同じ意味)でループしてやるといいですね。
16
+
17
+
18
+
13
- ```はおかしいですね。
19
+ ```javascript
20
+
21
+ let waypoint = document.getElementsByName('waypoints[]');
22
+
23
+ let waypts = [];
24
+
25
+ [].forEach.call(waypoint, function(ele) {
26
+
27
+ waypts.push({location: ele.value, stopover: true});
28
+
29
+ });
30
+
31
+ ```ちょっと`waypts`の配列をどういう風に処理するか分からなかったので適当です。