Number Guesser Challenge Project (JavaScript)

Hello All,
You can find my code for Number Guess project in my github.

https://sheriffhammed.github.io/script.js

https://aimes13.github.io/Number-Guesser-Project/

Hi everyone,
my code is on https://github.com/carolinascarneiro/number-guesser. I’m not sure about the logics I used, please let me know if you find anything wrong with the logics of my code. Thank you so much :slight_smile:

My solution on GitHub

That’s some slick code, only 10 lines in total.
Inspiring how you packed that ‘compareGuesses’ function into a single line.

1 Like

Here you go guys, let me know -

// Write your code below:
const generateTarget = () => {
  return Math.floor(Math.random() * 10);
};

const compareGuesses = (human, computer, secretTarget) => {
  if((human > 0)&&(human < 9)&&(computer > 0)&&(computer < 9)) {
  let humanDifference = getAbsoluteDistance(human, secretTarget);
  let computerDifference = getAbsoluteDistance(computer, secretTarget);

  return humanDifference <= computerDifference ? true : false;}
  else{alert('Number out of range!');}
};

const getAbsoluteDistance = (valueOne, valueTwo) => Math.abs(valueOne - valueTwo);

const updateScore = Winner => Winner === 'human' ? humanScore++ : computerScore++ ; 

const advanceRound = () => currentRoundNumber++;

Hi beautiful people!!

Just finished this tiny project and everything seems to be working fine.
Take a peak at it and let me know what you think:

Good vibes from Portugal :man_surfing: :raised_hands: