Number Guesser

Hi,

I am working on Number Guesser exercise. I can’t find out the reason why it is not showing the winner results. Please any help will be much appreciated.

let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

// Write your code below:

//Step 3

const generateTarget = () => {

return Math.floor(Math.random() * 9);

};

//Step 4

const compareGuesses = (currentHumanGuess,computerGuess,generateTarget) => {

let humanDifference = Math.abs (generateTarget - currentHumanGuess);

let computerDifference = Math.abs (generateTarget - computerGuess);

    if (humanDifference >= computerDifference) {

        return true;

    } else {

        return false;

    };

};

I don’t know if this is all the code you have in the exercise, but do you actually call your functions in your code?

The following is the code I have added to the exercise. step 3 is working and it is generating a random number. The problem is Step 4 when I need to compare the numbers, it is not showing anything and I can’t find why. Thanks.

//Step 3

const generateTarget = () => {

return Math.floor(Math.random() * 9);

};

//Step 4

const compareGuesses = (currentHumanGuess,computerGuess,generateTarget) => {

let humanDifference = Math.abs (generateTarget - currentHumanGuess);

let computerDifference = Math.abs (generateTarget - computerGuess);

    if (humanDifference >= computerDifference) {

        return true;

    } else {

        return false;

    };

};

Hello! Welcome to the community.

Can you try putting some console.log to see the values? Also, can you include a link to the lesson?