Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 4, 2020 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/2b0eae4fe672bb6e10766ba53d6243be to your computer and use it in GitHub Desktop.
Save codecademydev/2b0eae4fe672bb6e10766ba53d6243be to your computer and use it in GitHub Desktop.
Codecademy export
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// The random number:
let generateTarget = () => {
return Math.floor(Math.random()*9);
};
// Compare the guess number between computer, user and target number
let compareGuesses = (human, computer, target) =>{
const userG = Math.abs(target-human);
const computerG = Math.abs(target-computer);
return userG <= computerG;
}
// Add to the score number to winner
const updateScore = winner =>{
if (winner === 'computer'){
computerScore += 1;
} else{
humanScore += 1;
}
}
// add to round number after each round
const advanceRound = () =>{
currentRoundNumber += 1;
};
@Raminkeshavarzi
Copy link

I am a new programmer. These codes are one part of a project in the Codecademy Web Development course. At first glance, it was a bit tricky to build it because there where several ways to write these codes. However, I tried to pay attention to the importance of controlling the complexity of the program.
I would be highly grateful if you could write your opinion about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment