Skip to content

Instantly share code, notes, and snippets.

@codecademydev

codecademydev/script.js Secret

Created Sep 22, 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 = () => {
randomNumber = Math.floor(Math.random()*10);
return randomNumber
}// esta funcion genera una numero aleatorio del 0 al 9 y sera llamando en distintas instancias
//console.log (generateTarget());
const compareGuesses = (userGuess,computerGuess,secretTarget) => {
if(Math.abs(userGuess - secretTarget) < Math.abs(computerGuess- secretTarget)){
return true
}else if(Math.abs(userGuess - secretTarget) > Math.abs(computerGuess- secretTarget)){
return false
}else{
return true
}
}
//console.log (compareGuesses(2,5,2));
const updateScore = winner => {
if(winner === 'human'){
humanScore +=1;
}else if(winner === 'computer') {
computerScore +=1;
}
}
//updateScore ('human');
//console.log(humanScore);
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.