回答編集履歴
3
サンプルソース修正
test
CHANGED
@@ -16,15 +16,15 @@
|
|
16
16
|
|
17
17
|
class ArrayList {
|
18
18
|
|
19
|
-
constructor(){ let array = []; this.
|
19
|
+
constructor(){ let array = []; this.toArray = ()=>{return array;}; }
|
20
20
|
|
21
|
-
add(item){ this.
|
21
|
+
add(item){ this.toArray().push(item); return this; }
|
22
22
|
|
23
|
-
get(index){ return this.
|
23
|
+
get(index){ return this.toArray()[index]; }
|
24
24
|
|
25
|
-
forEach(callback){ return this.
|
25
|
+
forEach(callback){ return this.toArray().forEach(callback); }
|
26
26
|
|
27
|
-
indexOf(item){ return this.
|
27
|
+
indexOf(item){ return this.toArray().indexOf(item); }
|
28
28
|
|
29
29
|
};
|
30
30
|
|
2
サンプルソース修正
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
サンプルソースの引数修正
test
CHANGED
@@ -18,13 +18,13 @@
|
|
18
18
|
|
19
19
|
constructor(){ this.arr = []; }
|
20
20
|
|
21
|
-
add(
|
21
|
+
add(item){ this.arr.push(item); return this; }
|
22
22
|
|
23
23
|
get(index){ return this.arr[index]; }
|
24
24
|
|
25
|
-
forEach(a
|
25
|
+
forEach(callback){ return this.arr.forEach(callback); }
|
26
26
|
|
27
|
-
indexOf(
|
27
|
+
indexOf(item){ return this.arr.indexOf(item); }
|
28
28
|
|
29
29
|
};
|
30
30
|
|