-
-
Save codecademydev/94808c002b151c6500d38ccf6bbd6e20 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let humanScore = 0; | |
let computerScore = 0; | |
let currentRoundNumber = 1; | |
// Write your code below: | |
const generateTarget = () => Math.floor(Math.random() * 9); | |
const compareGuesses = (plyrGuess, cpuGuess, target) => { | |
human = Math.abs(plyrGuess - target); | |
computer = Math.abs(cpuGuess - target); | |
if (plyrGuess === cpuGuess) { | |
return true; | |
} else if (human < computer) { | |
return true; | |
} else if (human > computer) { | |
return false; | |
} | |
} | |
const updateScore = winner => { | |
if (winner === 'human') { | |
humanScore++; | |
} else { | |
computerScore++; | |
} | |
}; | |
const advanceRound = () => currentRoundNumber++; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment