Number guesser game, score and round not updating

Hey, all I am currently working through the number guesser game that is in the full-stack engineer career path and I am having trouble updating the score and round. When I log the functions to the console they work but when I try to actually play the game neither of them update properly.

let humanScore = 0; let computerScore = 0; let currentRoundNumber = 1; // generates random target number const generateTarget = () => Math.floor(Math.random() * 10) const targetGuess = generateTarget() // determines winner const compareGuesses = (humanGuess, computerGuess, targetGuess) => { const humanDiff = Math.abs(humanGuess - targetGuess); const computerDiff = Math.abs(computerGuess - targetGuess); if (humanDiff <= computerDiff) { return true } else { return false } } // score tallying const updateScore = winner => { if (result === 'human') { humanScore += 1 } else { computerScore += 1 } } // round advancing function advanceRound() { currentRoundNumber++ }

I want to make it clear that I am not looking for the answers just some direction as to why when logging the functions in the console they work as intended but they do not work when I am actually playing the game.
With the updateScore function I am having trouble understanding human and computer will pass through the winner parameter, although this may be going on in the game.js file that supplements this. With the advanceRound function I actually don’t know if it works or not because ‘next round’ is greyed out on the game, maybe because the round never ends since the score isn’t updated? Thank you!

It’s a common pattern in games that to start playing there’s a play() loop pattern (until user quits). Currently you have functions defined that outline the functionality of what a round/rounds would behave like, but no main() or play() to get the ball rolling (that is, the logic that continues to call the necessary function per every round in the necessary game logic).

I know this is an exercise from the course but I’m not sure I remember there being something to get it going… it’s just left as an exercise to the curious reader.

Thanks for the quick reply! In the exercise there are open ended steps that define the 4 functions that I have to code which are the ones that I wrote, there is also a game.js file that pulls the functions which is why they have to be named the right way so I am not sure if the play() function is defined in there. The first function is called because a target number is generated when I make a guess.

The second function compareGuesses I assume the true or false return is translated through to the strings ‘human’ and ‘computer’ which pass through then pass through to the third function but I don’t think it is doing that.

Sorry that I am all over the place this is the first time I am reaching out for coding help so I don’t know what is useful and I am also trying to think through the exercise as I am typing this.

Looking at it again I think the issue is somewhere in the compareGuesses function. Is it possible it isn’t able to pull in the first two parameters once generated which results in the following two functions not working?

Well I fixed it, the updateScore function wasn’t working because I was referencing “result” instead of the parameter “winner” because I changed the original name for some reason. A bit embarrassing but at least I completed it.