Skip to content

Instantly share code, notes, and snippets.

@codecademydev

codecademydev/script.js Secret

Created Sep 6, 2020
Embed
What would you like to do?
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
function generateTarget(){
return Math.floor(Math.random() * 10);
}
const compareGuesses= (user, guess,secretTarget) =>{
if(user===guess)
return true;
const x= Math.abs(secretTarget-guess);
const y= Math.abs(secretTarget-user);
if(y>x)
return false;
return true;
}
const updateScore = winner =>{
if(winner==="human")
humanScore++;
else
computerScore++;
/*if(hummanScor>=computerScore)
return "human";
return "computer";
*/
};
const advanceRound = () =>{
currentRoundNumber++;
}
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.