 # Hi everyone!C'ant understand how to return true and false as a result of function compareGuesses()!

let humanScore = 0; let computerScore = 0; let currentRoundNumber = 1; // Write your code below: //Generating a random target number between 0 and 9 function generateTarget() { let randomNr = Math.floor(Math.random() * 10); return randomNr; } //Determine which guess is closest to the target Number function compareGuesses(currentHumanGuess, computerGuess, target) { target = generateTarget(); if(Math.abs(currentHumanGuess - target) < Math.abs(computerGuess - target)) { return true; } else if (Math.abs(currentHumanGuess - target) === Math.abs(computerGuess - target)) { return true; } else { return false; } } console.log(compareGuesses()); //Increase winner's score after each round function updateScore(winner) { } //Update the round number after each round function advanceRound() { return currentRoundNumber++; }

Examples:

const same = (a, b) => { return a === b; // the expression is evaluated first then the result is returned } console.log(same(4, '4')); console.log(same('hello', 'hello'));

Hi! Do not really understand what you mean.Can you explain your example another one?Thanks!

If you run the code, you see that `false` and `true` are returned and printed to the console. Rather than typing out:

``````if(a === b) {
return true;
} else {
return false;
}
``````

We can simply return the evaluated value of the expression:

``````return a === b;
``````
1 Like

Yep.Thanks!Solved!!!

1 Like