From a59825117c3668812773f8ec1251f8cf8cf5a233 Mon Sep 17 00:00:00 2001 From: heather Date: Thu, 28 Jan 2016 16:53:04 -0500 Subject: [PATCH 1/3] work in progress --- class_3.js | 114 +++++++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/class_3.js b/class_3.js index 6e014e9..a6e892f 100644 --- a/class_3.js +++ b/class_3.js @@ -1,51 +1,63 @@ -// var billAmount = 666; -// function gratuity(somethingelse){ -// return somethingelse * .2 -// -// } -// -// console.log(gratuity(billAmount)) -// -// function totalWithGrat(amount) { -// return gratuity() + amount; -// -// console.log -// } -// var hands = ["rock", "paper", "scissors"]; -// function getHand() { -// var myIndex = parseInt(Math.random()*10)%3; -// return hands[myIndex]; -// }; -// -// var playerOne = { -// name: "mariah", -// getHand: getHand -// }; -// -// var playerTwo = { -// name: "minaj" -// getHand: getHand -// }; -// -// function playRound() { -// console.log(playerOne.name, playerTwo) -// -// }; - - -function outer(){ - var a = "what" - var b = {"bucket"} - - console.log(outer()) - - function inner (a,b) { - var a = "why" - var b = {"fuckit."} - - } - -inner(a,b); -} - -outer(); + +var hands = ["rock", "paper", "scissors"]; + function getHand() { + var myIndex = parseInt(Math.random()*10)%3; + return hands[myIndex]; + }; + +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) + } +}; + + +}; From 93043491c7165b84e8f6a8a02692f6acfd638490 Mon Sep 17 00:00:00 2001 From: Shane Barringer Date: Sat, 30 Jan 2016 16:10:17 -0500 Subject: [PATCH 2/3] fixes minor typos --- class_3.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/class_3.js b/class_3.js index 302c069..f8369f2 100644 --- a/class_3.js +++ b/class_3.js @@ -3,7 +3,7 @@ var hands = ["rock", "paper", "scissors"]; function getHand() { var myIndex = parseInt(Math.random()*10)%3; return hands[myIndex]; - }; + } var playerOne = { name: "mariah", @@ -15,7 +15,6 @@ var playerTwo = { getHand: getHand }; -<<<<<<< HEAD var playerOneScore = 0 var playerTwoScore = 0 @@ -62,7 +61,7 @@ playGame(playerOne, playerTwo, 5) }; -======= + function playRound() { console.log(playerOne.name, playerTwo) From 4fe57e290cab67be726b97ef5bfc3bb95da2aa75 Mon Sep 17 00:00:00 2001 From: juliangrimes Date: Sat, 30 Jan 2016 16:22:18 -0500 Subject: [PATCH 3/3] updates player object --- class_3.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/class_3.js b/class_3.js index f8369f2..8c7ff23 100644 --- a/class_3.js +++ b/class_3.js @@ -1,8 +1,8 @@ var hands = ["rock", "paper", "scissors"]; function getHand() { - var myIndex = parseInt(Math.random()*10)%3; - return hands[myIndex]; + + return hands[parseInt(Math.random()*10)%3]; } var playerOne = { @@ -11,7 +11,7 @@ var playerOne = { }; var playerTwo = { - name: "minaj" + name: "minaj", getHand: getHand };