Skip to content

Instantly share code, notes, and snippets.

@codecademydev

codecademydev/script.js Secret

Created Sep 10, 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=(user,computer,target)=>{
let diffUser=Math.abs(target-user);
let diffComp=Math.abs(target-computer);
if(diffUser <= diffComp )
return true;
else
return false;
}
const updateScore=(winner)=>{
if(winner==='human')
humanScore+=1;
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.