Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created October 13, 2020 15:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save codecademydev/fac5aba230b17ca51b1a05479bc337c2 to your computer and use it in GitHub Desktop.
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
// Genera el nuevo número aleatorio.
const generateTarget = () => {
return Math.floor(Math.random() * 10);
};
const compareGuesses = (humanGuess, computerGuess, targetGuess) => {
const humanDifference = Math.abs(targetGuess - humanGuess);
const computerDifference = Math.abs(targetGuess - computerGuess);
return humanDifference <= computerDifference;
};
const updateScore = winner => {
if (winner === 'human') {
humanScore++;
} else if (winner === 'computer') {
computerScore++;
}
};
const advanceRound = () => currentRoundNumber++;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment