回答編集履歴
1
まともな回答の追加
answer
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
```js
|
|
2
|
+
var r = Math.floor(Math.random() * liRandom.length);
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
上の部分で乱数生成している様に見えるので、これを choice関数のなかでやればクリックされるたびに違う変数が生成されるように思うので、以下の様に choice 関数を修正されてはどうですか。
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
var choice = function(){
|
|
9
|
+
var r = Math.floor(Math.random() * liRandom.length);
|
|
10
|
+
console.log(liRandom[r]);
|
|
11
|
+
console.log(liRandom[r]);
|
|
12
|
+
if(r === 0){
|
|
13
|
+
document.getElementById('zOne').textContent = '';
|
|
14
|
+
}
|
|
15
|
+
if(r === 1){
|
|
16
|
+
document.getElementById('zTwo').textContent = '';
|
|
17
|
+
}
|
|
18
|
+
if(r === 2){
|
|
19
|
+
document.getElementById('zThree').textContent = '';
|
|
20
|
+
}
|
|
21
|
+
if(r === 3){
|
|
22
|
+
document.getElementById('zFour').textContent = '';
|
|
23
|
+
}
|
|
24
|
+
if(r === 4){
|
|
25
|
+
document.getElementById('zFive').textContent = '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
1
33
|
余裕ですね。…そう、 React ならね。
|
|
2
34
|
|
|
3
35
|
[https://codepen.io/og24715/pen/QxoYLM?editors=0010](https://codepen.io/og24715/pen/QxoYLM?editors=0010)
|