-
-
Save codecademydev/723d39736114cb30be2d99d3c06db819 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 = randomNumber => { | |
return Math.floor(Math.random() * 9); | |
} | |
const compareGuesses = (human, computer, target) => { | |
let compDiff = Math.abs(target - computer); | |
let humanDiff = Math.abs(target - human); | |
if (human === computer) { | |
return true; | |
} | |
else if (humanDiff < compDiff) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
updateScore('human'); | |
console.log(humanScore); | |
updateScore('computer'); | |
console.log(computerScore); | |
const advanceRound = (currentRoundNumber) => { | |
return currentRoundNumber++; | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment