Challenge Project Number Guesser

Hello all,

I am currently working on the Number Guesser challenge and I am getting some syntax errors that I cannot quite figure out.

The main one is that my < is getting a unexpected token error.

Any ideas would be greatly appreciated.

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

// Write your code below:
const generateTarget = Math.floor(Math.random() * 10)

const compareGuesses = (humanGuess, computerGuess, targetGuess) => { 
  if (Math.abs(humanGuess - targetGuess)) < (Math.abs(computerGuess - targetGuess))
    return true;                                                  
    else if (Math.abs(humanGuess - targetGuess) > (Math.abs(computerGuess-targetGuess))
  return false; 
}

const updateScore = (winner) => {
  if (winner === humanScore);
  humanScore++;
  else if (winner === computerScore);
  computerScore++;
}

const advanceRound = () => {
  currentRoundNumber++;
}
updateScore('human');
console.log(humanScore); // To confirm that this value increased by 1
updateScore('computer');
console.log(computerScore); // To confirm that this value increased by 1


Many thanks :+1:

1 Like

You have many syntax errors in your code mainly because you do not have correct brackets and after the if statement you need to open curly brackets.

Recheck your code and look for those mistakes.

1 Like

Thank you.
I am no longer getting any errors but I am just getting the numbers:

1
2

…in the viewer. Is that correct or have I made another mistake?

I mean you have to compare your goal of the exercise with your output. Does it match or you made a logic mistake?

1 Like