-
-
Save codecademydev/17bf6130923868c7dbb164fc98ea5477 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let humanScore = 0; | |
let computerScore = 0; | |
let currentRoundNumber = 1; | |
function generateTarget() | |
{ | |
return Math.floor(Math.random()*10); | |
} | |
function compareGuesses(userGuess,compGuess,targetNum) | |
{ | |
let a = Math.abs(targetNum-userGuess); | |
let b = Math.abs(targetNum-compGuess); | |
if(a<=b) | |
return true; | |
else | |
return false; | |
} | |
function updateScore(winner) | |
{ | |
if(winner === 'human') | |
humanScore++; | |
else | |
computerScore++; | |
} | |
function advanceRound() | |
{ | |
currentRoundNumber++; | |
} | |
function alert() | |
{ | |
if (userGuess<0 || userGuess>9) | |
console.log('Number must be between 0 and 9'); | |
} | |
// Write your code below: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment