What is wrong with my code - help please

this is my code for the number guesser project. sth seems off as the next round button and the score counter dont work properly. you can find the project here https://www.codecademy.com/projects/practice/number-guesser-independent-practice. please help

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

// Write your code below:

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

const compareGuesses = (hGuess, cGuess, tNumber) => {
  if (Math.abs(hGuess - tNumber) <= Maths.abs(cGuess - tNumber)) {
    return true;
  } else if (Math.abs(hGuess - tNumber) > Maths.abs(cGuess - tNumber)) {
    return false;
  }
};

const updateScore = (winner) => {
  if (winner == "human") {
    return humanScore++;
  }
  if (winner == "computer") {
    return computerScore++;
  }
};

const advanceRound = () => {
  return currentRoundNumber++;
};

Starting with step 1:

generateTarget() […] should return a random integer between 0 and 9.

Your code returns numbers between 0 and 8.

Then you must see an error in the console:

Maths is not defined

It’s Math – not Maths. Check your spelling: Sometimes its correctly spelled – sometimes not.

2 Likes

cant thank you enough

1 Like