Number Guesser Project

I’m working on the Number Guesser Project on JavaScript Syntax Part 1.

When running my code. I noticed a few things.

  1. it’s not comparing the user guess with computer guess
  2. not calculating the round number
  3. not accurately calculating/ updating the score when user or computer guesses the number.

I don’t think I set up the function compareGuess properly. My goal here was to compare the difference between what the user guess to what the computer guessed and compare that to the guess value.

Also from my understanding to increment a variable we can say variable += 1 but it appears my functions aren’t calculating these properly. May someone look at my code below to see what I missed?

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

// Write your code below:
const generateTarget = () => {
  return Math.floor(Math.random() * (9-0) + 1)

const compareGuess = (userGuess, computerGuess, secret) => {
  if (Math.abs(secret - userGuess) <= Math.abs(secret -computerGuess) ) {
    return true;
  } else {
    return false;

const updateScore = winner => {
if (winner === 'human') {
  humanScore += 1;
} else {
  compterScore += 1;

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

Hello, and welcome to the forums

If you bring up your browser’s console, you can see any error messages being produced so you know how to proceed. You can access the console by pressing
Shift + CTRL + J (Windows / Linux)
Option + + J (Mac)

Alternatively, you can press F12 and click on the Console tab.

Your suspicions about what’s going wrong are in the right ballpark, but not for the reasons you suspect.

Click for another hint

The first error you’ll see is about compareGuesses() not being defined. The front-end for the guessing game was provided by Codecademy and it’s supposed to be calling the function that you created, but you didn’t name it correctly.

Click for another hint

The next error will be triggered when the computer wins after the fix the last issue. If you look closely at the error message, you’ll discover the typo in your variable name.

Awesome, I see what I did. I set up variables this time to make it easier to compare the difference to make it easier for my if…else statements…

thank you