Skip to content

Instantly share code, notes, and snippets.

@codecademydev

codecademydev/script.js Secret

Last active Sep 8, 2020
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);
};
const compareGuesses = (humanNum, computerNum, secretNum) => {
let userGuess = Math.abs(secretNum - humanNum);
let computerGuess = Math.abs(secretNum - computerNum);
if(userGuess < computerGuess){
return true;
}else{
return false
}
};
const updateScore = (winner) => {
if(winner === 'human'){
humanScore += 1;
}else if(winner === 'computer'){
computerScore += 1;
}
};
const advanceRound = () => {
currentRoundNumber += 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.