numberGuesser javaScript

Hi everybody:
i am a bit stuck in the numberguesser exercise
i have checked with the completed exercise and the code seems to me to be the same but i cant make work still.
maybe a new set of eyes can see where is the mistake
thanks in advanced.

let computerScore = 0;
let currentRoundNumber = 1;

// Write your code below:
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1 ;

// Write your code below:


const generateTarget = () =>{
    let randomNUmber = Math.floor(Math.radom()*10);
    return randomNumber;
}


const compareGuesses = (humanGuess,computerGuess,Targetguess) =>{
let humandifference = Math.abs(Targetguess -  humanGuess);
let computerDifference = Math.abs(Targetguess - computerGuess);
return humanDifference <= computerDifference;


}
}

const updateScore = (winner) => {
if( winner === 'human'){
    humanScore ++;
    
}else if (winner === 'computer'){
computerScore ++;
}
}
 const advanceRound = () =>{
 currentRoundNUmber ++ ;
 }

Hello, @pedroro.

Look closely at your { }'s. They should be in pairs. I count 13 total, so … :wink:

thanks i had one loose } but still not working

1 Like

Do you have an error message?
I copied your code, and ran it in place of my own in the project. If you read the error messages, you’ll see line numbers that show you where the problems are, and you should be able to fix them. It will help you tremendously to open your browser console, so you can see all of the error messages. (They won’t all appear in the console window provided by the Codecademy Learning Environment.)

Hint

You have many spelling errors. You can try to find them by proof reading, or you can follow the error messages. Following the error messages is debugging (a valuable skill). Proof reading is much less effective, and more time consuming.

After removing the extra }, I ran your code (clicked Save). I received the following error message in the CC console window below the code editor:

/home/ccuser/workspace/independent-practice-js-number-guesser/script.js:5
let computerScore = 0;
^
SyntaxError: Identifier ‘computerScore’ has already been declared

It’s referring to line 5. (Notice the end of the first line of the error message: script.js:5)
The message says that computerScore has already been declared, so look above line 5. Has it already been declared?

Link to project for reference.

i decided to start fresh and yeah… my spelling was a mess. thanks you helped me a lot !

1 Like