Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 9, 2020 20:26
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/548e31fb95069283b089dd9371c04d90 to your computer and use it in GitHub Desktop.
Save codecademydev/548e31fb95069283b089dd9371c04d90 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 getTarget = () => {
return Math.floor(Math.random() * 10);
}
const compareGuesses = (humanGuess, computerGuess, target) => {
if (Math.abs(target - humanGuess) < Math.abs(target - computerGuess || Math.abs(target - humanGuess) === Math.abs(target - computerGuess)) return true;
} else { return false;
}
let updateScore = winner => {
humanScore ++ === 'human';
computerScore ++ === 'Computer';
}
let advanceRound = currentRoundNumber => {
return currentRoundNumber ++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment