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

質問編集履歴

1

期待している結果についての追記

2020/07/15 03:02

投稿

nanase21
nanase21

スコア144

title CHANGED
File without changes
body CHANGED
@@ -5,9 +5,15 @@
5
5
  ```js
6
6
  const arr = [1,3];
7
7
  const obj = [
8
- {id: 1, quantity: 1, name: 'product1'},
8
+ {id: 1, quantity: 1, name: 'product1', sample: [0,4]},
9
- {id: 2, quantity: 3, name: 'product2', sample: [1,2],
9
+ {id: 2, quantity: 3, name: 'product2', sample: [1,2]},
10
10
  ]
11
- console.log(obj.filter(e => e.sample.includes(arr[0])))
11
+ console.log(obj.filter(e => e.sample.includes(arr)))
12
12
  // => []
13
- ```
13
+ ```
14
+
15
+ 指摘事項への追記
16
+
17
+ **期待している結果**
18
+ sampleの中身に対してarrの値がが含まれていれば該当jsonを返します。
19
+ ``=> {id: 2, quantity: 3, name: 'product2', sample: [1,2]}``