Number Guesser: Score and Round not updating

Hi All,

I’m having trouble updating the score and the round number of my number guesser project. Please have a look at my code and give me your advice. Once the user makes a guess, there is no winner or option to go to the next round. The console isn’t printing any error messages either.

https://www.codecademy.com/practice/projects/number-guesser-independent-practice

let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

// Write your code below:

function generateTarget() {

  return Math.floor(Math.random() * 10);

}

console.log(generateTarget());

const compareGuesses = (userGuess, computerGuess, targetNumber) => { if (Maths.abs(userGuess - targetNumber) >= Maths.abs(computerGuess - targetNumber))

{return false;

}

else if (Maths.abs(userGuess - targetNumber) <= Maths.abs(computerGuess - targetNumber)) 

{return true; 

}

}

function updateScore(winner) {

  if (compareGuesses) {humanScore += 1;

  } else {

    computerScore += 1;

  }

}

advanceRound = () => {

  let currentRoundNumber = currentRoundNumber + 1;

}

Hello, @margueriteo, and welcome to the forums.

You should review the instructions for task #5. There are only two possible values that will be passed as the argument for your parameter, winner. You need to use your if condition to determine which one it is.

Then, here:

You are declaring and defining a new variable named currentRoundNumber that only has local scope because you used the keyword let. What you want to do is update the already existing variable that was defined at the beginning of your code.

Hint:

Just leave out let.

currentRoundNumber += 1;
//or better yet:
currentRoundNumber++;
1 Like