# Challenge Project: Number Guesser

Hey everyone! I just completed the Number Guesser Challenge Project while working on the Full Stack Engineer Path and I just wanted to show my code here so that I could get some feedback on how I could make my code more efficient/concise and some best practices that I may have overlooked. Thank you and have a great day!

Project: Number Guesser Challenge Project in Module 9 of the Full Stack Engineer Path (JavaScript Syntax part 1) (It doesn’t let me use the link for some reason, sorry for the inconvenience)

``````let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;

const generateTarget = () => {
return Math.floor(Math.random() * 10);
};

const getAbsoluteDistance = (num1, num2) => {
return Math.abs(num1 - num2);
}

const compareGuesses = (userGuess, computerGuess, target) => {

if (userGuess < 0 || userGuess > 9) {
alert('Your number is out of range! Enter a number from 0 to 9.');
}
if (userGuess === computerGuess) {
return true;
} else if ((getAbsoluteDistance(userGuess, target)) < (getAbsoluteDistance(computerGuess, target))) {
return true;
} else if ((getAbsoluteDistance(userGuess, target)) > (getAbsoluteDistance(computerGuess, target))) {
return false;
}
};

const updateScore = winner => {

if (winner === 'human') {
humanScore += 1;
} else if (winner === 'computer') {
computerScore += 1;
}
};

const advanceRound = () => {
currentRoundNumber += 1;
};
``````