Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 10, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/1e999ee21f2ac884237e24a6db044da5 to your computer and use it in GitHub Desktop.
Save codecademydev/1e999ee21f2ac884237e24a6db044da5 to your computer and use it in GitHub Desktop.
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
function generateTarget(){
return Math.floor(Math.random() * 10);
};
function compareGuesses(human, computer, target){
if(human === computer){
return true;
} else if(human === target || Math.abs(human - target) < Math.abs(computer - target){
return true;
} else if(computer === target || Math.abs(computer - target) < Math.abs(human - target){
return false;
}
};
function updateScore(winner){
if(winner === 'human'){
humanScore += 1;
} else if(winner === 'computer'){
computerScore +=1;
}
};
function advanceRound(){
currentRoundNumber += 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment