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