回答編集履歴
1
chousei
test
CHANGED
@@ -24,17 +24,17 @@
|
|
24
24
|
|
25
25
|
const view=document.querySelector('#view');
|
26
26
|
|
27
|
-
q.split(' ')
|
27
|
+
const q_arr=q.split(' ')
|
28
28
|
|
29
29
|
.map(x=>[x,Math.random()])
|
30
30
|
|
31
31
|
.sort((x,y)=>x[1]-y[1])
|
32
32
|
|
33
|
-
.map(x=>x[0])
|
33
|
+
.map(x=>x[0]);
|
34
34
|
|
35
|
-
|
35
|
+
q_arr.forEach(x=>view.append(Object.assign(document.createElement('div'),{textContent:x})));
|
36
36
|
|
37
|
-
const a=[];
|
37
|
+
const a_arr=[];
|
38
38
|
|
39
39
|
document.querySelectorAll('#view div').forEach(x=>{
|
40
40
|
|
@@ -42,15 +42,15 @@
|
|
42
42
|
|
43
43
|
if(!e.target.closest('[data-disabled]')){
|
44
44
|
|
45
|
-
a.push(e.target.textContent);
|
45
|
+
a_arr.push(e.target.textContent);
|
46
46
|
|
47
47
|
e.target.setAttribute('data-disabled',1);
|
48
48
|
|
49
|
-
ans.textContent=a.join(" ");
|
49
|
+
ans.textContent=a_arr.join(" ");
|
50
50
|
|
51
|
-
if(a
|
51
|
+
if(a_arr.length==q_arr.length){
|
52
52
|
|
53
|
-
|
53
|
+
document.querySelector('#judge').textContent=q==ans.textContent?'正解!':'不正解';
|
54
54
|
|
55
55
|
}
|
56
56
|
|
@@ -62,11 +62,11 @@
|
|
62
62
|
|
63
63
|
document.querySelector('#reset').addEventListener('click',e=>{
|
64
64
|
|
65
|
-
a.length=0;
|
65
|
+
a_arr.length=0;
|
66
66
|
|
67
67
|
document.querySelectorAll('[data-disabled]').forEach(x=>x.removeAttribute('data-disabled'));
|
68
68
|
|
69
|
-
document.querySelector('#ans').textContent='';
|
69
|
+
document.querySelectorAll('#ans,#judge').forEach(x=>x.textContent='');
|
70
70
|
|
71
71
|
});
|
72
72
|
|
@@ -82,4 +82,6 @@
|
|
82
82
|
|
83
83
|
<div id="judge"></div>
|
84
84
|
|
85
|
+
|
86
|
+
|
85
87
|
```
|