Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created Nov 5, 2019
Embed
What would you like to do?
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
const generateTarget = () => {
return Math.floor(Math.random() * 10);
}
console.log(generateTarget());
const compareGuesses = (humanScore, computerScore, targetNumber) => {
const humanDifference = Math.abs(targetNumber - humanScore);
const computerDifference = Math.abs(targetNumber - computerScore);
return humanDifference <= computerDifference;
}
const updateScore = (winner) =>{
if(winner === 'human'){
humanScore++;
}else if(winner === 'computer') {
comuterScore ++;
}
}
const advanceRound = () => {
return currentRoundNumber++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment