-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommitMessage-Final
93 lines (85 loc) · 3.91 KB
/
CommitMessage-Final
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
3-20
turn console.log into DOM
function playRound() {
computerSelection = getComputerChoice();
if (playerSelection === computerSelection) {
console.log('It is a tie!');
} else if ((playerSelection === 'rock') && (computerSelection == 'paper')) {
console.log('You lose! Paper beats Rock!');
} else if ((playerSelection === 'paper') && (computerSelection == 'scissors')) {
console.log('You lose! Scissors beats Paper!');
} else if ((playerSelection === 'scissors') && (computerSelection == 'rock')) {
console.log('You lose! Rock beats Scissors!');
} else if ((computerSelection === 'paper') && (playerSelection === 'scissors')) {
console.log('You win! Rock beats Paper!');
} else if ((computerSelection === 'rock') && (playerSelection === 'paper')) {
console.log('You win! Scissors beats Paper!');
} else if ((computerSelection === 'scissors') && (playerSelection === 'rock')) {
console.log('You win! Rock beats Scissors!');
} else {console.log('Error in playRound() if else statement!!!');
}
}
to
function playRound() {
computerSelection = getComputerChoice();
if (playerSelection === computerSelection) {
singleResultsText = 'It is a tie!';
} else if ((playerSelection === 'rock') && (computerSelection == 'paper')) {
singleResultsText = 'You lose! Paper beats Rock!';
} else if ((playerSelection === 'paper') && (computerSelection == 'scissors')) {
singleResultsText = 'You lose! Scissors beats Paper!';
} else if ((playerSelection === 'scissors') && (computerSelection == 'rock')) {
singleResultsText = 'You lose! Rock beats Scissors!';
} else if ((computerSelection === 'paper') && (playerSelection === 'scissors')) {
singleResultsText = 'You win! Rock beats Paper!';
} else if ((computerSelection === 'rock') && (playerSelection === 'paper')) {
singleResultsText = 'You win! Scissors beats Paper!';
} else if ((computerSelection === 'scissors') && (playerSelection === 'rock')) {
singleResultsText = 'You win! Rock beats Scissors!';
} else {
console.log('Error in playRound() if else statement!!!');
}
}
3-23-2023
have made the displayed running score updated whenever the score changes
have made changes to the code so winner and final score are announced when one player hit 5 points
have stopped the scores and results of a single round from changing when buttons are clicked, when one player reacehs 5 points
make function addPoint() shorter according to https://jsfiddle.net/snowMonkey/p6uo4k8z/2/:
change
function addPoint() {
if (playerSelection === computerSelection) {
noPointComputer();
noPointPlayer();
} else if (playerSelection === 'rock' && computerSelection === 'paper'){
addPointComputer();
noPointPlayer();
} else if (playerSelection === 'paper' && computerSelection === 'scissors') {
addPointComputer();
noPointPlayer();
} else if (playerSelection === 'scissors' && computerSelection === 'rock') {
addPointComputer();
noPointPlayer();
} else if (playerSelection === 'paper' && computerSelection === 'rock') {
addPointPlayer();
noPointComputer();
} else if (playerSelection === 'scissors' && computerSelection === 'paper') {
addPointPlayer();
noPointComputer();
} else if (playerSelection === 'rock' && computerSelection === 'scissors') {
addPointPlayer();
noPointComputer();
} else (console.log('Error in if else statement of addPoint()!!'))
}
to
function addPoint(result) {
if (result.startsWith('You lose!')) {
addPointComputer();
noPointPlayer();
} else if (result.startsWith('You win!')) {
addPointPlayer();
noPointComputer();
} else if (result.startsWith('It is a tie')) {
noPointComputer();
noPointPlayer();
} else (console.log('Error in if else statement of addPoint()!!'))
}