Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 11, 2020 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codecademydev/9c6124b6833a4ed88fae9c9940f41e60 to your computer and use it in GitHub Desktop.
Save codecademydev/9c6124b6833a4ed88fae9c9940f41e60 to your computer and use it in GitHub Desktop.
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
function generateTarget(){
return Math.floor(Math.random()*10)
}
function compareGuesses(human,computer,target){
var humanClose=Math.abs(human-target);
var computerClose=Math.abs(computer-target);
if(computerClose>=humanClose){
return true
}
else{
return false
}
}
function updateScore(string){
if(string === "human"){
humanScore+=1
}
else{
computerScore+=1
}
}
function advanceRound(currentRoundNumber){
return currentRoundNumber+=1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment