回答編集履歴
1
サンプルソース追加
test
CHANGED
@@ -13,3 +13,33 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
上と同じく「ball」が4回入力されたら、というのをカウントする必要がありますね。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
### 追記
|
20
|
+
|
21
|
+
ちなjavascriptならこんな感じ。
|
22
|
+
|
23
|
+
```javascript
|
24
|
+
|
25
|
+
((s=0,b=0)=>{
|
26
|
+
|
27
|
+
while(s < 3 && b < 4){
|
28
|
+
|
29
|
+
let j = window.prompt('input your judgement');
|
30
|
+
|
31
|
+
if(j=='strike'){ console.log('strike ' + ++s); }
|
32
|
+
|
33
|
+
if(j=='ball'){ console.log('ball ' + ++b); }
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
if(s>=3){console.log('out!');}
|
38
|
+
|
39
|
+
if(b>=4){console.log('four ball!');}
|
40
|
+
|
41
|
+
})()
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```
|