-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay1.js
57 lines (49 loc) · 1.69 KB
/
play1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
document.addEventListener('DOMContentLoaded',function() {
let score1 = 0
let score2 = 0
while(true)
{
document.querySelector('#runinput1_button').addEventListener('click',function (){
let userrun = parseInt(document.querySelector('#runinput1').value);
let cmprun = Math.floor(Math.random() * 7);
document.querySelector('#enteredrun_1').innerHTML = "You entered " + userrun;
document.querySelector('#compchosenrun').innerHTML = "Computer chose " + cmprun;
if(userbat)
{
document.querySelector('#status').innerHTML = "You are batting"
if(userrun == cmprun)
{
feedback4.innerHTML = "you are out :("
break;
}
else
{
score1 += userrun
document.querySelector('#player_runs').innerHTML = "Your current run is " + score1
}
}
else{
document.querySelector('#status').innerHTML = "You are bowling"
if(userrun != cmprun)
{
score2 += cmprun
document.querySelector('#computer_runs').innerHTML = "Computer's run is " + score2
}
else
{
feedback4.innerHTML = "Computer is out :)"
break;
}
}
})
}
if(userbat)
{
let fate = "You are"
}
else
{
let fate = "Computer is "
}
document.querySelector('#feedback6').innerHTML = fate + " out"
})