Skip to content

Instantly share code, notes, and snippets.

@nicole-cal
Created October 4, 2021 09:54
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 nicole-cal/63767528b245f8bff06c77d9fc3b97ce to your computer and use it in GitHub Desktop.
Save nicole-cal/63767528b245f8bff06c77d9fc3b97ce to your computer and use it in GitHub Desktop.
Number Guesser Codecademy JS
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
function generateTarget() {
min = Math.ceil(0);
max = Math.floor(9);
return Math.floor(Math.random() * 9)
};
function compareGuesses(userGuess, computerGuess, secretTarget) {
return Math.abs(userGuess - secretTarget);
return Math.abs(computerGuess - secretTarget);
computerGuess > userGuess ? true : 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