Number Guesser

Hello , i am literally stuck on this project , i have problems with updateScore function and advanceRound function , can you help me ?

let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;

// Write your code below:
const generateTarget = () => {
    Math.floor(Math.random() * 10)
    return (Math.floor(Math.random() * 10));

}
// Compare Guess
const compareGuesses = (userGuess,computerGuess,secretTargetNumber) => {
 secretTargetNumber = generateTarget();
 const humanValue = Math.abs(userScore-computerGuess);
 const computerValue = Math.abs(computerGuess-userGuess);
 if(humanValue >= computerValue) {
     return true;
 }else if(computerValue > humanValue) {
     return false;
 }
 
}
// Update Score
const updateScore = (winner) => {
    if(updateScore === 'human') {
        humanScore++;
    }else if(updateScore === 'computer') {
        computerScore++;
    }
    
}
// AdvanceRound
const advanceRound = (currentRoundNumber) => {
    currentRoundNumber++;
}

Hi,

Thanks for sharing your code. Consider your function:

const updateScore = (winner) => {
    if(updateScore === 'human') {
        humanScore++;
    }else if(updateScore === 'computer') {
        computerScore++;
    }
}

the way you’re declaring the arrow function is thus:

const functionName = (paramater) => {
    //some actions
}

Consider: are you using the parameter inside the function?

Worked , thank you !

const updateScore = (winner) => {
    if(winner  === 'human') {
        humanScore++;
    }else if(winner === 'computer') {
        computerScore++;
    }
}
1 Like