-
-
Save codecademydev/ef60e072be42d7c1398163cb521c7373 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 = () => { | |
return Math.random(Math.Floor() * 10) | |
}; | |
const compareGuesses = (human, computer, target) => { | |
if (Math.abs(human - target) < Math.abs(computer - target)) { | |
return true; | |
} else if (Math.abs(computer - target) < Math.abs(human - target)) { | |
return false; | |
} else { | |
return true; | |
} | |
}; | |
const updateScore = (winner) => { | |
if (winner === 'human') { | |
humanScore += 1; | |
} else if (winner === 'computer') { | |
computerScore += 1; | |
} else { | |
return humanScore += 1; | |
} | |
}; | |
const advanceRound = () => { | |
currentRoundNumber += 1 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment