回答編集履歴

2

2

2021/05/13 23:32

投稿

takasima20
takasima20

スコア7466

test CHANGED
@@ -76,7 +76,7 @@
76
76
 
77
77
  {name:"A1Yes",miss:["Cabbage","Cactus"]},
78
78
 
79
- {name:"A1No"miss:["Elephant","Giraffe","MichaelJackson","NobunagaOda"]},
79
+ {name:"A1No",miss:["Elephant","Giraffe","MichaelJackson","NobunagaOda"]},
80
80
 
81
81
  //(略)
82
82
 

1

1

2021/05/13 23:32

投稿

takasima20
takasima20

スコア7466

test CHANGED
@@ -61,3 +61,47 @@
61
61
  //(略)
62
62
 
63
63
  ```
64
+
65
+ --- 追記 ---
66
+
67
+ コードを短くするなら、諸条件を配列で持ちループで処理するのがよくあるかな。
68
+
69
+ ```javascript
70
+
71
+ //(略)
72
+
73
+
74
+
75
+ const pat = [
76
+
77
+ {name:"A1Yes",miss:["Cabbage","Cactus"]},
78
+
79
+ {name:"A1No"miss:["Elephant","Giraffe","MichaelJackson","NobunagaOda"]},
80
+
81
+ //(略)
82
+
83
+ ];
84
+
85
+
86
+
87
+ for (let i=0; i<pat.length; i++) {
88
+
89
+ if (document.getElementById(pat[i].name).checked) {
90
+
91
+ for (let j=0; j<pat[i].miss.length; j++) {
92
+
93
+ Judge[pat[i].miss[j]] = "不正解";
94
+
95
+ }
96
+
97
+ }
98
+
99
+ }
100
+
101
+
102
+
103
+ //(略)
104
+
105
+ ```
106
+
107
+ あ、デバッグしてないので間違ってたらごめん