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

回答編集履歴

2

テキスト修正

2020/01/06 03:08

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -5,6 +5,12 @@
5
5
  を使わなくても、標準の [filter](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) を使って以下でよいかと思います。
6
6
 
7
7
  ```javascript
8
+ let list = [
9
+ "13-10", "12-11", "13-11", "13-12", "12-12", "13-13",
10
+ "13-14", "13-15", "13-16", "13-17", "12-13"];
11
+
8
- const filteredList = list.filter(e => e.startsWith('13-'));
12
+ list = list.filter(e => e.startsWith('13-')); // => '13-' で始まる要素を抽出
13
+
14
+ console.log(list);
9
15
  ```
10
16
  - **動作確認用 CodePen: **[https://codepen.io/jun68ykt/pen/ExaoZbd?editors=0012](https://codepen.io/jun68ykt/pen/ExaoZbd?editors=0012)

1

テキスト修正

2020/01/06 03:08

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -6,4 +6,5 @@
6
6
 
7
7
  ```javascript
8
8
  const filteredList = list.filter(e => e.startsWith('13-'));
9
- ```
9
+ ```
10
+ - **動作確認用 CodePen: **[https://codepen.io/jun68ykt/pen/ExaoZbd?editors=0012](https://codepen.io/jun68ykt/pen/ExaoZbd?editors=0012)