回答編集履歴
1
サンプルソース追加
answer
CHANGED
@@ -5,4 +5,19 @@
|
|
5
5
|
|
6
6
|
> 'ball'4回で'fourball'
|
7
7
|
|
8
|
-
上と同じく「ball」が4回入力されたら、というのをカウントする必要がありますね。
|
8
|
+
上と同じく「ball」が4回入力されたら、というのをカウントする必要がありますね。
|
9
|
+
|
10
|
+
### 追記
|
11
|
+
ちなjavascriptならこんな感じ。
|
12
|
+
```javascript
|
13
|
+
((s=0,b=0)=>{
|
14
|
+
while(s < 3 && b < 4){
|
15
|
+
let j = window.prompt('input your judgement');
|
16
|
+
if(j=='strike'){ console.log('strike ' + ++s); }
|
17
|
+
if(j=='ball'){ console.log('ball ' + ++b); }
|
18
|
+
}
|
19
|
+
if(s>=3){console.log('out!');}
|
20
|
+
if(b>=4){console.log('four ball!');}
|
21
|
+
})()
|
22
|
+
|
23
|
+
```
|