Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 23, 2020 10:25
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/682eadb94ca450e4ca972e166b4158df to your computer and use it in GitHub Desktop.
Save codecademydev/682eadb94ca450e4ca972e166b4158df to your computer and use it in GitHub Desktop.
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// The random number:
let generateTarget = () => {
return Math.floor(Math.random()*9);
};
// Compare the guess number between computer, user and target number
let compareGuesses = (human, computer, target) =>{
const userG = Math.abs(target-human);
const computerG = Math.abs(target-computer);
return userG <= computerG;
}
// Add to the score number to winner
const updateScore = winner =>{
if (winner === 'computer'){
computerScore += 1;
} else{
humanScore += 1;
}
}
// add to round number after each round
const advanceRound = () =>{
currentRoundNumber += 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment