-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
45 lines (36 loc) · 1.12 KB
/
main.js
File metadata and controls
45 lines (36 loc) · 1.12 KB
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
var score = document.getElementById('Score');
var playing = document.getElementById('playing');
var input = document.getElementById('input');
var playerOne = document.getElementById('playerone');
var playerTwo = document.getElementById('playertwo');
var reset = document.getElementById('reset');
var playerOneScore = 0;
var playerTwoScore = 0;
var max = 5;
function playerOnePressed(e) {
if(playerOneScore < max)
{
playerOneScore++;
score.innerText = playerOneScore + " to " + playerTwoScore;
}
}
function playerTwoPressed(e) {
if(playerTwoScore < max)
{
playerTwoScore++;
score.innerText = playerOneScore + " to " + playerTwoScore;
}
}
function resetPressed(e) {
playerTwoScore = 0;
playerOneScore = 0;
score.innerText = playerOneScore + " to " + playerTwoScore;
}
function inputBox(e) {
max = input.value;
playing.innerText = "Playing to: " + max;
}
playerOne.addEventListener('click', playerOnePressed);
playerTwo.addEventListener('click', playerTwoPressed);
reset.addEventListener('click',resetPressed);
input.addEventListener('input',inputBox);