Number Guesser Problem with making the score go up

Hello, below is the code I wrote for the Number Guesser question. I am really stumped on getting the humanScore or computerScore to go up? not sure what’s wrong.

let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

let randomPersonGuess = Math.floor(Math.random() * 9) + 1;

let randomComputerGuess = Math.floor(Math.random() * 9) + 1;

const generateTarget = Math.floor(Math.random() * 9) + 1;

console.log(generateTarget + " random number");

console.log(randomPersonGuess + " generated human guess");

console.log(randomComputerGuess + " generated computer guess");

const compareGuesses = (human = randomPersonGuess, computer = randomComputerGuess, number = generateTarget) => {

let userGuess = Math.abs(human - number);

let computerGuess = Math.abs(computer - number);

if (computerGuess >= userGuess) {

return true;

} else {

return false;




function updateScore(){


return humanScore += 1


return computerScore += 1 





Hello @net5575189438, welcome to the forums!
It doesn’t appear that you’re actually calling the updateScore() function. Remember, functions must be called in order for the code within them to be executed.

1 Like

I think that generateTarget should be a function, not a number.

You don’t need the return in the updateScore function. (The purpose of the function is to update a variable, not to give you a value.)
I think that function updateScore needs to have a parameter, and compareGuesses is not the appropriate variable to use in that if-statement. (Maybe a function call: compareGuesses() should replace compareGuesses, but I think the instructions say to do something else.)
Here’s a link to another post on that: post 5 (about task 6-7)


Math.floor(Math.random() * 9) + 1;

generates a number from 1 to 9, not 0 to 9.

Step 5 instructions

Create an updateScore() function. This function will be used to correctly increase the winner’s score after each round.

This function:

  • Has a single parameter. This parameter will be a string value representing the winner.
  • Increases the score variable ( humanScore or computerScore ) by 1 depending on the winner passed in to updateScore . The string passed in will be either 'human' or 'computer' .
  • Does not need to return any value.
1 Like