質問編集履歴
2
コードの追記、returnの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
以下が模範回答です。
|
4
4
|
|
5
5
|
```js
|
6
|
+
|
7
|
+
var ladders = [
|
8
|
+
|
9
|
+
{ id: 1, height: 20 },
|
10
|
+
|
11
|
+
{ id: 3, height: 25}
|
12
|
+
|
13
|
+
]
|
14
|
+
|
15
|
+
|
6
16
|
|
7
17
|
function findWhere(array, criteria) {
|
8
18
|
|
@@ -32,9 +42,19 @@
|
|
32
42
|
|
33
43
|
```js
|
34
44
|
|
45
|
+
var ladders = [
|
46
|
+
|
47
|
+
{ id: 1, height: 20 },
|
48
|
+
|
49
|
+
{ id: 3, height: 25}
|
50
|
+
|
51
|
+
]
|
52
|
+
|
53
|
+
|
54
|
+
|
35
55
|
function findWhere(array, criteria) {
|
36
56
|
|
37
|
-
array.find(element => {
|
57
|
+
return array.find(element => {
|
38
58
|
|
39
59
|
var property = Object.keys(criteria);
|
40
60
|
|
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,6 +15,12 @@
|
|
15
15
|
})
|
16
16
|
|
17
17
|
}
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
findWhere(ladders, { height: 25 })
|
22
|
+
|
23
|
+
// result: { id: 3, height 25 }
|
18
24
|
|
19
25
|
```
|
20
26
|
|
@@ -38,4 +44,10 @@
|
|
38
44
|
|
39
45
|
}
|
40
46
|
|
47
|
+
|
48
|
+
|
49
|
+
findWhere(ladders, { height: 25 })
|
50
|
+
|
51
|
+
// result: { id: 3, height 25 }
|
52
|
+
|
41
53
|
```
|