Currently learning web development, after completing HTML/CSS I'm now in JavaScript fundamentals (boy is it way tougher than the first two!), and in this practice project I'm looking to grab the absolute values of userGuess - secretActualNumber and computerGuess - secretActualNumber, and then compare them to see which one is closer to the secret number. So far I've tried this.
const compareGuesses = (userGuess , computerGuess, secretActualNumber) => {
Math.abs(userGuess-secretActualNumber);
Math.abs(computerGuess-secretActualNumber);
}
In order to compare both of those, I was thinking I need to implement the "difference" function of JS. But I've been struggling to make use that, to compare these two items, and to then result in a true/false. (true being if the user is closer, and false if the computer is closer).
Let me know what you think!
Thanks in advance