-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.js
46 lines (37 loc) · 1.07 KB
/
helper.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
function capitalize(string) {
return string.at(0).toUpperCase() + string.substring(1).toLowerCase();
}
function removeAllChildNodes(parent) {
while (parent.firstElementChild) {
parent.removeChild(parent.firstElementChild);
}
}
let youWinText = 'You win this round and score a point!';
let computerWinsText = 'Computer wins this round and scores a point!';
let drawText = 'This round is a draw! No points are scored.';
function compareHands(humanChoice, computerChoice) {
if (humanChoice === computerChoice) {
return drawText;
} else if (humanChoice === 'Rock') {
switch (computerChoice) {
case 'Scissors':
return youWinText;
case 'Paper':
return computerWinsText;
}
} else if (humanChoice === 'Paper') {
switch (computerChoice) {
case 'Rock':
return youWinText;
case 'Scissors':
return computerWinsText;
}
} else if (humanChoice === 'Scissors') {
switch (computerChoice) {
case 'Paper':
return youWinText;
case 'Rock':
return computerWinsText;
}
}
}