# Number Guesser Project - Help needed

Hey, guys. I started this project and so far I have been having a lot of issues unlike with the previous JavaScript projects. I started building it out but I can’t seem to find the reason why it doesn’t work. See the code below:

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

const generateTarget = () => {
return Math.floor(Math.random() * 10)
}

const compareGuesses = function(humanGuess, computerGuess, targetGuess) {
if (humanGuess == computerGuess) {
return true;
} else if (Math.abs(humanGuess - targetGuess) > Math.abs(computerGuess - targetGuess)) {
return false;
} else if (Math.abs(humanGuess - targetGuess) < Math.abs(computerGuess - targetGuess)) {
return true;
}
}

const updateScore = (winner) => {
if (compareGuesses = true) {
humanScore += 1;
} else if (compareGueses = false) {
computerScore +=1;
}
}
``````

As you can see I haven’t finished it yet, but this is because the score is not getting updated with the code I wrote.

Thanks in advance for anyone who has time to look into this!

1 Like

Check the operators in your if / else if statements. They should be comparison operators.

this = that (sets this equal to that)
this === that (asks: is this equal to that?)

So I changed ‘=’ to ‘===’ in updateScore function, see below :

``````const updateScore = (winner) => {

if (compareGuesses === true) {

humanScore += 1;

} else if (compareGueses === false) {

computerScore +=1;

}

}
``````

But when I save it, it still doesn’t work and the core stays at 0 no matter how many times I try.

You are comparing a function (`compareGuesses`) type with a boolean type. How is that comparison suppose to go?

What do you want to compare here? You want to check who won, right? where does this value come from? maybe the `winner` parameter?

given either the human or computer wins, shouldn’t `if` and `else` be sufficient? why would you need `else if`?

1 Like

Thanks for the answers, I found the issue and finished the project!