# Number guesser - now sure why it won't work

Hi!
I’ve just completed the Number guesser exercise, and I’m not sure why it won’t run.

I wrote this:

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

// Write your code below:

function generateTarget ()
{
return Math.floor(Math.random() * 10);
}

function compareGuesses (humanGuess, computerGuess, targetGuess)
{
if (math.abs(targetGuess - humanGuess))
< (math.abs(targetGuess - computerGuess))
{return true}
else
{return false}

}

function updateScore (winner) {

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

}

return currentRoundNumber++;
}
``````

I checked the solution and the second function was defined like this:

``````const compareGuesses = (humanGuess, computerGuess, targetGuess) => {
const humanDifference = Math.abs(targetGuess - humanGuess)
const computerDifference = Math.abs(targetGuess - computerGuess)
return humanDifference <= computerDifference;
}
``````

And if I replace mine with this one, it runs.

What did I do wrong in that function?

Won’t run?
How far does it get?
Is the file executed?
What’s the first thing that should happen, does that happen?

It doesn’t even let me click on the button.

Is your mouse plugged in?
That’s what would stop you from clicking it, isn’t it.

There’s some series of events that you are expecting to happen. What is that? How far does that go?

…I meant nothing happens when I click.

OK, now I get why.

I didn’t realize that the if statement wasn’t fully inside round brackets:

``````if (math.abs(targetGuess - humanGuess))
< (math.abs(targetGuess - computerGuess))
``````

Now it works:

``````if ((math.abs(targetGuess - humanGuess))
< (math.abs(targetGuess - computerGuess)))
``````

Stupid mistake really, but I’m glad it the function was otherwise ok