回答編集履歴

3

サンプルソース修正

2018/06/18 15:06

投稿

tkturbo
tkturbo

スコア5572

test CHANGED
@@ -16,15 +16,15 @@
16
16
 
17
17
  class ArrayList {
18
18
 
19
- constructor(){ let array = []; this.arr = ()=>{return array;}; }
19
+ constructor(){ let array = []; this.toArray = ()=>{return array;}; }
20
20
 
21
- add(item){ this.arr().push(item); return this; }
21
+ add(item){ this.toArray().push(item); return this; }
22
22
 
23
- get(index){ return this.arr()[index]; }
23
+ get(index){ return this.toArray()[index]; }
24
24
 
25
- forEach(callback){ return this.arr().forEach(callback); }
25
+ forEach(callback){ return this.toArray().forEach(callback); }
26
26
 
27
- indexOf(item){ return this.arr().indexOf(item); }
27
+ indexOf(item){ return this.toArray().indexOf(item); }
28
28
 
29
29
  };
30
30
 

2

サンプルソース修正

2018/06/18 15:06

投稿

tkturbo
tkturbo

スコア5572

test CHANGED
@@ -16,15 +16,15 @@
16
16
 
17
17
  class ArrayList {
18
18
 
19
- constructor(){ this.arr = []; }
19
+ constructor(){ let array = []; this.arr = ()=>{return array;}; }
20
20
 
21
- add(item){ this.arr.push(item); return this; }
21
+ add(item){ this.arr().push(item); return this; }
22
22
 
23
- get(index){ return this.arr[index]; }
23
+ get(index){ return this.arr()[index]; }
24
24
 
25
- forEach(callback){ return this.arr.forEach(callback); }
25
+ forEach(callback){ return this.arr().forEach(callback); }
26
26
 
27
- indexOf(item){ return this.arr.indexOf(item); }
27
+ indexOf(item){ return this.arr().indexOf(item); }
28
28
 
29
29
  };
30
30
 

1

サンプルソースの引数修正

2018/06/18 14:46

投稿

tkturbo
tkturbo

スコア5572

test CHANGED
@@ -18,13 +18,13 @@
18
18
 
19
19
  constructor(){ this.arr = []; }
20
20
 
21
- add(value){ this.arr.push(value); return this; }
21
+ add(item){ this.arr.push(item); return this; }
22
22
 
23
23
  get(index){ return this.arr[index]; }
24
24
 
25
- forEach(args){ return this.arr.forEach(args); }
25
+ forEach(callback){ return this.arr.forEach(callback); }
26
26
 
27
- indexOf(val){ return this.arr.indexOf(val); }
27
+ indexOf(item){ return this.arr.indexOf(item); }
28
28
 
29
29
  };
30
30