Hiya, I’m having some issues with the code below. Whenever I play the game the computer always wins and is added to score even when the human should win. I don’t understand why it keeps returning false. Please help, thank you.
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
const generateTarget = () => {
return Math.floor(Math.random ()*10);
}
const compareGuesses = (human, computer, target) => {
target= generateTarget;
if (Math.abs(target - human) < Math.abs(target - computer)) {
return true;
}
if (Math.abs(target - human) === Math.abs(target- computer)) {
return true;}
else {
return false
}
}
const updateScore = winner => {
winner = compareGuesses;
if (winner === 'human'){
humanScore = humanScore + 1
}
else {
computerScore += 1;
}
}
const advanceRound = currentRoundNumber =>{
currentRoundNumber = currentRoundNumber += 1
}