-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrps_lm_aw.js
More file actions
40 lines (38 loc) · 1.78 KB
/
rps_lm_aw.js
File metadata and controls
40 lines (38 loc) · 1.78 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
//The first time the game runs the values for oneWeaponOfChoice and twoWeaponOfChoice log undefined
var onePlayerName = "Latori";
var twoPlayerName = "Amy";
var oneScore = 0;
var twoScore = 0;
var weapons = ["a rock" , "paper", "scissors"];
while (oneScore < 3 && twoScore < 3){
console.log("Rock, Paper, Scissors Shoot!");
console.log("Anything you want to do! :-)");
var oneWeaponOfChoice = weapons[parseInt(Math.random()*weapons.length) %3];
var twoWeaponOfChoice = weapons[parseInt(Math.random()*weapons.length) %3];
console.log(onePlayerName +" has " + oneWeaponOfChoice);
console.log(twoPlayerName + " has " + twoWeaponOfChoice);
if (oneWeaponOfChoice === "a rock" && twoWeaponOfChoice === "paper"){
console.log(twoPlayerName + " wins this round!");
twoScore++;
} else if (oneWeaponOfChoice === "paper" && twoWeaponOfChoice === "a rock"){
console.log (onePlayerName + " wins this round!");
oneScore++;
} else if (oneWeaponOfChoice === "scissors" && twoWeaponOfChoice === "a rock"){
console.log(twoPlayerName + " wins this round!");
twoScore++;
} else if (oneWeaponOfChoice === "scissors" && twoWeaponOfChoice === "paper"){
console.log (onePlayerName + " wins this round!");
oneScore++;
} else if (oneWeaponOfChoice === "a rock" && twoWeaponOfChoice === "scissors"){
console.log(onePlayerName + " wins this round!");
oneScore++;
} else if (oneWeaponOfChoice === "paper" && twoWeaponOfChoice === "scissors"){
console.log (twoPlayerName + " wins this round!");
twoScore++;
} else {console.log("We have a tie!");
}
}
if (oneScore == 3){
console.log (onePlayerName + ", congratulations! You've won three games.")
} else {console.log (twoPlayerName + ", congratulations! You've won three games.")
}