Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 28, 2020 10:49
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/ef60e072be42d7c1398163cb521c7373 to your computer and use it in GitHub Desktop.
Save codecademydev/ef60e072be42d7c1398163cb521c7373 to your computer and use it in GitHub Desktop.
Codecademy export
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