-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
42 lines (35 loc) · 1.08 KB
/
script.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
let xScore = '0';
let yScore = '0';
function getComputerChoice() {
let choices = ["Kámen", "Papír", "Nůžky"];
return choices[(
Math.round(
Math.random()*(choices.length-1)
)
)]
}
function getPlayerChoice() {
let PlayerChoice = prompt("Vyber volbu", "");
PlayerChoice = PlayerChoice.toUpperCase();
return PlayerChoice;
}
function playRound() {
let x = getComputerChoice();
let y = getPlayerChoice();
console.log("PC: "+x);
console.log("Hráč: "+y);
if(x == "Kámen" && y == "NŮŽKY" || x == "Nůžky" && y == "PAPÍR" || x == "Papír" && y == "KÁMEN") {
console.log("prohra");
xScore = ++xScore;
} else if(x == "Kámen" && y == "STONE" || x == "Nůžky" && y == "NŮŽKY" || x == "Papír" && y == "PAPÍR") {
console.log("remiza");
}
else
{
console.log("vyhra");
yScore = ++yScore;
}
console.log("PC Skóre: "+xScore);
console.log("Hráč Skóre: "+yScore);
console.log("___________________");
}