Number Guesser

I am not sure why my updateScore() and advanceRound() functions are not working in the browser here. Everything else is working and I think I implemented them following directions in the same way I did the other functions.

let humanScore = 0;

let computerScore = 0;

let currentRoundNumber = 1;

// Write your code below:

generateTarget = () =>{

let randNum = Math.floor(Math.random() * 10);

return randNum;

}

// console.log(generateTarget());

const compareGuesses = (user, comp, targ) =>{

let userDiff;

let compDiff;

if(user <= targ){

userDiff = targ - user;

}

else if(user > targ){

userDiff = user - targ;

}

// else if(user === targ){

// return true;

// }

if(comp <= targ){

compDiff = targ - comp;

}

else if(comp > targ){

compDiff = comp - targ;

}

// else if(comp === targ){

// return false;

// }

if(userDiff <= compDiff){

return true;

}

else if(userDiff > compDiff){

return false;

}

}

// console.log(compareGuesses(8, 8, 3));

const updateScore = (winner) =>{

let humanScore = 0;

let computerScore = 0;

if(winner === ‘human’){

humanScore ++;

}

else if(winner === ‘computer’){

computerScore ++;

}

console.log(humanScore);

console.log(computerScore);

}

updateScore(‘computer’);

const advanceRound = () => {

let currentRoundNumber = 0;

currentRoundNumber ++;

console.log(currentRoundNumber);

}

advanceRound();

1 Like

Hi, welcome to the forums :slight_smile:

When you get a chance, can you format your post? (It will allow people to help you faster and more efficiently). See here [How to] Format code in posts - #7.