Number guesser https://www.codecademy.com/practice/projects/number-guesser-independent-practice

Something’s wrong with my code… I’ve tried my best but I get this error message in console: ReferenceError: Invalid left-hand side in assignment


let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

// Write your code below:

const generateTarget = (x, y) = > {

  Math.floor(Math.random()*8)

}

generateTarget();

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

target = generateTarget();

computerGuess = generateTarget();

if (computerGuess === target && userGues !== target) {

  return false

} else if (computerGuess !== target && userGuess === target) {

  return true

} 

}

compareGuesses();

const updateScore = (e) => {

  var humanScore = 0;

  var computerScore = 0;

if (compareGuesses()=true) {

humanScore++

} else if (compareGuesses()=false){

  computerScore++

}

updateScore();

const advanceRound = () => {

  currentRoundNumber++

}

advanceRound();

If you google the error code message the first thing that comes up is

The JavaScript exception " invalid assignment left - hand side " occurs when there was an unexpected assignment somewhere. For example, a single " = " sign was used instead of " == " or " === ".

Take a look at your else if block at the end of your code with the above in mind.

Take a look at your generateTarget function definition. Something about it is different to the others. :slight_smile: