Number guesser challenge project

Can somebody explain what I did wrong with this? When I play the game, no matter what the outcome is, it always says the computer wins, but I get a point.

Here is my full code


if (compareGuesses)

compareGuesses is the function. Which will always evaluate to true. Why would you use compareGuesses in this condition?

Well I guess I am kind of confused about what the true and false values represent in the if/else if statement that I wrote.

Make sure to follow the project steps closely. There are multiple JavaScript files in this project but you are only writing one of them.

Right, and I only edited the script.js file, is there something else I should be doing?

maybe you should log/print this value then? To see what it

It just comes out as [function: compareGuesses]. So now I understand why that would always evaluate to true, but I’m still a bit confused as to what I would put instead of that. In the solution I see they put

const updateScore = winner => {
if (winner === ‘human’) {
} else if (winner === ‘computer’) {

but I don’t really get where the ‘human’ and ‘computer’ values come from.

when you call the updateScore function, you can pass a string (argument).

1 Like

Ok thank you that makes sense, but for some reason the computer always wins, even if my guess is closer.

Here is my updated code

What exactly are you trying to accomplish with line 12: secretNumber = generateTarget ?

1 Like

Same advise as earlier: logging/print if you don’t know something or to inspect parts of your code

1 Like

I was trying to set the secretNumber parameter equal to the random number I got in the generateTarget function which doesn’t really make sense I guess. I removed that and it fixed it thank you!