回答編集履歴
1
見直し
test
CHANGED
@@ -25,3 +25,39 @@
|
|
25
25
|
}
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
配列1000個になるのを防ぐ書き方に見直し。
|
34
|
+
|
35
|
+
```javascript
|
36
|
+
|
37
|
+
let hist = new Array();
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
for (let i = 1; i <= 1000; i++) {
|
42
|
+
|
43
|
+
hist.push(Math.floor(Math.random() * 31));
|
44
|
+
|
45
|
+
if (hist.length > 3) {
|
46
|
+
|
47
|
+
hist.shift();
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
if (hist[0] === hist[1] === hist[2]) {
|
52
|
+
|
53
|
+
break;
|
54
|
+
|
55
|
+
} else {
|
56
|
+
|
57
|
+
console.log(hist[hist.length-1]);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
```
|