回答編集履歴

3

ソース修正

2022/09/07 08:32

投稿

Matsumon0104
Matsumon0104

スコア1005

test CHANGED
@@ -8,7 +8,7 @@
8
8
  ```javascript
9
9
  return vm.people.filter(function(person) {
10
10
  if (Array.isArray(person.category)) {
11
- return person.category.include(category);
11
+ return person.category.includes(parseInt(category));
12
12
  } else {
13
13
  return person.category === category;
14
14
  }

2

文言修正

2022/09/07 08:17

投稿

Matsumon0104
Matsumon0104

スコア1005

test CHANGED
@@ -3,7 +3,7 @@
3
3
  「配列 === 数値」は「false」なので、「イチロー」が出ていないのかと思います。
4
4
 
5
5
  「filter」の処理で「配列」なのかそうじゃないのかで処理を分け、
6
- 「配列」であれば、その配列内に「category」が存在する場合にpresonを返し、
6
+ 「配列」であれば、その配列内に「category」が存在する場合にその「presonを返し、
7
7
  「配列」でなければ、今までの処理を行うとうまくいくのではないでしょうか。
8
8
  ```javascript
9
9
  return vm.people.filter(function(person) {

1

ソース修正

2022/09/07 08:16

投稿

Matsumon0104
Matsumon0104

スコア1005

test CHANGED
@@ -8,11 +8,9 @@
8
8
  ```javascript
9
9
  return vm.people.filter(function(person) {
10
10
  if (Array.isArray(person.category)) {
11
- if (person.category.include(category)) {
11
+ return person.category.include(category);
12
- return person;
12
+ } else {
13
- }
14
- return ['name': '', 'category': category];
13
+ return person.category === category;
15
14
  }
16
- return person.category === category;
17
15
  }
18
16
  ```