回答編集履歴
3
.
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
while(true){
|
20
20
|
|
21
|
-
let tmp = getRandom(min,max);
|
21
|
+
let tmp = getRandom(min,max);
|
22
22
|
|
23
23
|
if(!randoms.includes(tmp)){
|
24
24
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
while(true){
|
82
82
|
|
83
|
-
let tmp = getRandom(min,max);
|
83
|
+
let tmp = getRandom(min,max);
|
84
84
|
|
85
85
|
if(!randoms.includes(tmp)){
|
86
86
|
|
2
.
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
function getRandom(min,max){
|
10
10
|
|
11
|
-
return Math.floor(Math.random()*(max - min +1)+min);
|
11
|
+
return Math.floor(Math.random()*(max - min +1)+min);
|
12
12
|
|
13
13
|
}
|
14
14
|
|
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
if(!randoms.includes(tmp)){
|
24
24
|
|
25
|
-
randoms.push(tmp);
|
25
|
+
randoms.push(tmp);
|
26
26
|
|
27
|
-
break;
|
27
|
+
break;
|
28
28
|
|
29
29
|
}
|
30
30
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
let getRandom = function(min,max){
|
72
72
|
|
73
|
-
return Math.floor(Math.random()*(max - min +1)+min);
|
73
|
+
return Math.floor(Math.random()*(max - min +1)+min);
|
74
74
|
|
75
75
|
}
|
76
76
|
|
@@ -84,9 +84,9 @@
|
|
84
84
|
|
85
85
|
if(!randoms.includes(tmp)){
|
86
86
|
|
87
|
-
randoms.push(tmp);
|
87
|
+
randoms.push(tmp);
|
88
88
|
|
89
|
-
break;
|
89
|
+
break;
|
90
90
|
|
91
91
|
}
|
92
92
|
|
1
.
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
```
|
1
|
+
```javaScirpt
|
2
2
|
|
3
3
|
let randoms = [];
|
4
4
|
|
@@ -49,3 +49,59 @@
|
|
49
49
|
|
50
50
|
|
51
51
|
let → function に変えただけですが一応動くっぽいですね
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
---
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
関数式を使いたいならこうでしょうか?
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```javaScript
|
64
|
+
|
65
|
+
let randoms = [];
|
66
|
+
|
67
|
+
let min = 1,max = 10;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
let getRandom = function(min,max){
|
72
|
+
|
73
|
+
return Math.floor(Math.random()*(max - min +1)+min);
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
for (i = min; i <= max ; i++){
|
80
|
+
|
81
|
+
while(true){
|
82
|
+
|
83
|
+
let tmp = getRandom(min,max);
|
84
|
+
|
85
|
+
if(!randoms.includes(tmp)){
|
86
|
+
|
87
|
+
randoms.push(tmp);
|
88
|
+
|
89
|
+
break;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
console.log(randoms);
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
出力結果
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
[ 9, 10, 8, 2, 5, 7, 4, 1, 3, 6 ]
|
106
|
+
|
107
|
+
```
|