-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass_3.js
More file actions
68 lines (55 loc) · 1.67 KB
/
class_3.js
File metadata and controls
68 lines (55 loc) · 1.67 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var hands = ["rock", "paper", "scissors"];
function getHand() {
return hands[parseInt(Math.random()*10)%3];
}
var playerOne = {
name: "mariah",
getHand: getHand
};
var playerTwo = {
name: "minaj",
getHand: getHand
};
var playerOneScore = 0
var playerTwoScore = 0
function playRound(playerOne, playerTwo) {
playerOne = playerOne.hands()
playerTwo = playerTwo.hands()
var winner = 0;
if (playerOne = "Scissors" && playerTwo = "paper" ||
playerOne = "Rock" && playerTwo = "Scissors" ||
playerOne = "Paper" && playerTwo = "Rock"){
winner = playerOne.name;
playerOne.winner++;
console.log("mariah played " + playerOne + "and minaj played" + playerTwo + "so the elusive chanteuse wins!");
}
else if (playerOne !== playerTwo){
winner = playerTwo.name;
playerTwo.winner++;
"mariah played " + playerOne + "and minaj played" + playerTwo + "so the rap queen wins!");
}
else if (playerOne === playerTwo){
console.log("It's a tie");
}
function playGame(playerOne, playerTwo, playUntil) {
// var gameWinner
while (playerOne.winner < playUntil && playerTwo.winner < playUntil)
playRound(playerOne, playerTwo)
if playerOne === playUntil console.log(playerOne.name + " wins the whole enchilada")
else if playerTwo === playUntil
console.log("all friday's are pink from here on out, because" + playerTwo.name + wins it all)
}
// var calculator = {
// add: function(a,b) {
// return a + b;
// }
// }
//
// calculator.add(2,3) // 5
playGame(playerOne, playerTwo, 5)
}
};
};
function playRound() {
console.log(playerOne.name, playerTwo)
};