質問編集履歴
2
タイトルの修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jsで
|
1
|
+
jsでオブジェクトの配列を作成したい
|
test
CHANGED
File without changes
|
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,27 +4,19 @@
|
|
4
4
|
|
5
5
|
```javascript
|
6
6
|
|
7
|
-
let
|
7
|
+
let items = []
|
8
8
|
|
9
|
+
for (let index = 0; index < 3; index++) {
|
9
10
|
|
11
|
+
let item = { name: "Apple", price: index }
|
10
12
|
|
11
|
-
|
13
|
+
items.push(item)
|
12
14
|
|
13
|
-
ary.push(item1);
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
}
|
18
|
-
|
19
|
-
ary.push(item2);
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
console.log(ary)
|
24
16
|
|
25
17
|
```
|
26
18
|
|
27
|
-
![イメージ説明](
|
19
|
+
![イメージ説明](ca53640e59671d5990fd53cf9abe0bd3.png)
|
28
20
|
|
29
21
|
|
30
22
|
|
@@ -44,23 +36,15 @@
|
|
44
36
|
|
45
37
|
num.then((snapshot) => {
|
46
38
|
|
47
|
-
|
39
|
+
snapshot.docs.forEach((doc) => {
|
48
40
|
|
49
|
-
|
41
|
+
let hoge = { id: doc.id, name: doc.data().name }
|
50
42
|
|
51
|
-
|
43
|
+
huga.push(hoge)
|
52
44
|
|
53
|
-
|
45
|
+
})
|
54
46
|
|
55
|
-
}
|
56
|
-
|
57
|
-
huga.push(hoge)
|
58
|
-
|
59
|
-
|
47
|
+
})
|
60
|
-
|
61
|
-
})
|
62
|
-
|
63
|
-
console.log(huga)
|
64
48
|
|
65
49
|
```
|
66
50
|
|