Number Guesser completed but not working properly

NumberGuesser

There are no errors, but the round will only update 1 time and the “you win/computer wins” don’t function correctly.

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

// Write your code below:
const generateTarget= () => {
Math.floor(Math.random() * 9);
return Math.floor(Math.random() * 9);
};
generateTarget();
let targetNumber = generateTarget();
//#4
const humanGuess = (targetNumber, humanGuess) => {
  return Math.abs(a - b);
}
const computerGuess = (targetNumber, computerGuess) => {
  return Math.abs(a - b);
}

function compareGuesses(humanGuess, computerGuess, targetNumber){
  if(humanGuess <= computerGuess){
    return true
  }else{
    return false
  } 
  }
  compareGuesses()
//#5
function updateScore(string) {
  if(compareGuesses === true){
    humanScore = humanScore++
    return "you win!"
  }else if(compareGuesses === false){
    computerScore = computerScore++
    return "computer wins!"
  }
}
function advanceRound(){
  advanceRound = advanceRound++
}

I realize it’s the last two functions, but not sure what else to do based on the instructions, so any suggestion is appreciated.

What, exactly, is this meant to do? :slight_smile:

take the current round and increment it by 1

Right. So, the variable tracking the current round would be advanceRound?

I’m not so sure… :slight_smile:

Everything is an object in JavaScript, including functions. What you’re actually doing here is overriding the function with nonsense, because calling the increment operator on a function is meaningless…

Thanks… should be currentRoundNumber++.

also see that I don’t need to do that with

Blockquote

humanScore =

Blockquote

just humanScore++

Thanks for the help

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.