質問編集履歴
2
javascriptの間違っていた部分を訂正しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
javascriptのタイピングゲームで
|
1
|
+
javascriptのタイピングゲームで正解パターンができない
|
body
CHANGED
@@ -1,35 +1,31 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
javascriptでタイピングゲームを作っています。
|
3
|
-
|
3
|
+
正解パターンの表記ができません。
|
4
|
+
同じ文を打っても、間違いと出てしまいます。
|
4
5
|
### 発生している問題・エラーメッセージ
|
5
6
|
|
6
7
|
```
|
7
|
-
|
8
|
+
|
8
|
-
at init (game.js:46)
|
9
|
-
at game.js:41
|
10
9
|
```
|
11
10
|
|
12
11
|
### 該当のソースコード
|
13
12
|
|
14
|
-
```
|
13
|
+
```javascript
|
15
14
|
let subject = document.getElementById('subject');
|
16
15
|
let mytext = document.getElementById('myText');
|
17
16
|
let submit = document.getElementById('submit');
|
18
17
|
let currentTime = document.getElementById('currentTime');
|
19
18
|
|
20
19
|
let questionArray = [
|
21
|
-
'
|
20
|
+
'apple',
|
22
|
-
'How do you know Mr Smith?',
|
23
|
-
'May I introduce Mr Peel to you?',
|
24
|
-
'This is Sam, who is a friend of mine.',
|
25
|
-
'I don’t think we’ve been properly introduced. I am Ken.',
|
26
|
-
'
|
21
|
+
'banana',
|
22
|
+
'apple',
|
27
|
-
'
|
23
|
+
'banana',
|
24
|
+
'apple',
|
28
|
-
'
|
25
|
+
'banana'
|
29
26
|
];
|
30
27
|
|
31
|
-
|
32
|
-
let time =
|
28
|
+
let time = 60;
|
33
29
|
let count = 0;
|
34
30
|
let state = true
|
35
31
|
|
@@ -44,7 +40,7 @@
|
|
44
40
|
submit.addEventListener('click' , function(e){
|
45
41
|
if(!state) return;
|
46
42
|
|
47
|
-
if(mytext.value ==
|
43
|
+
if(mytext.value == submit.textContent) {
|
48
44
|
count++;
|
49
45
|
init();
|
50
46
|
} else {
|
@@ -55,14 +51,13 @@
|
|
55
51
|
init();
|
56
52
|
|
57
53
|
function init() {
|
58
|
-
const rnd = Math.floor(Math.random * questionArray.length);
|
54
|
+
const rnd = Math.floor(Math.random() * questionArray.length);
|
59
55
|
subject.textContent = questionArray[rnd];
|
60
56
|
mytext.value = ' ';
|
61
57
|
mytext.focus();
|
62
58
|
}
|
63
59
|
|
64
60
|
|
65
|
-
|
66
61
|
function finish() {
|
67
62
|
clearInterval(countdown);
|
68
63
|
subject.textContent = '正解数は' + count + "子でした";
|
@@ -81,9 +76,9 @@
|
|
81
76
|
</head>
|
82
77
|
<body>
|
83
78
|
<div class="typingGame">
|
84
|
-
<h1 id="subject"></h1>
|
79
|
+
<h1 id="subject">dkns</h1>
|
85
80
|
<input type="text" id="myText">
|
86
|
-
<
|
81
|
+
<button id="submit" >送信</button>
|
87
82
|
<p id="currentTime"></p>
|
88
83
|
</div>
|
89
84
|
|
@@ -97,6 +92,4 @@
|
|
97
92
|
|
98
93
|
|
99
94
|
|
100
|
-
### 補足情報(FW/ツールのバージョンなど)
|
95
|
+
### 補足情報(FW/ツールのバージョンなど)
|
101
|
-
|
102
|
-
カウントダウンの関数と終了時の関数は正常に動いてくれます。
|
1
エラーは無くなりましたが、ランダムに表示される問題文がh1タグ内に表示できません
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
javascript
|
1
|
+
javascriptのタイピングゲームで問題文の表示ができない
|
body
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
javascriptでタイピングゲームを作っています。
|
3
|
-
|
3
|
+
問題文の表示ができません。
|
4
|
-
|
5
4
|
### 発生している問題・エラーメッセージ
|
6
5
|
|
7
6
|
```
|