Number Guesser

Maybe I got the whole thing wrong, but why the target-number is still undefiened?

let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

// Write your code below:

const generateTarget = () =>{

Math.floor(Math.random() * 9);

};

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

const hguess = Math.abs(secretNumber - humanGuess);

const pcGuess = Math.abs ( secretNumber - computerGuess);

if (hguess > pcGuess) {

return true

} else if (pcGuess > hguess){

return false;

} else if (hguess === pcGuess){

return true;

} else{

return ‘Something Went Wronog’;

};

};

const updateScore = winner =>{

if (winner => ‘humanGuess’){

return humanScore++;

} else if (winner = ‘computerGuess’){

return computerScore++;

}else {

return ‘Something Went Wrong’;

};

};

const advanceRound = () =>{

currentRoundNumber++;

}

Take a look at your generateTarget function. The project instructions state the function needs to return a number.

2 Likes