Number Guesser Confusion (I'm not sure what I'm supposed to do because it seems the game.js does much of it)

I’m working on the Number Guesser project but I’m not sure what I’m supposed to do because it seems the game.js does much of it.

In the instructions, it says we don’t need to look at the game.js code. I assumed the game.js was handling additional things that made the game work. But the game.js it has this code:

// Generate the target value
  target = generateTarget();
  // Retrieve the player's guess
  const currentHumanGuess = humanGuessInput.value;
  // Make a random 'computer guess'
  const computerGuess = Math.floor(Math.random() * 10);

  // Display the computer guess and the target
  computerGuessDisplay.innerText = computerGuess;
  targetNumberDisplay.innerText = target;
  
  // Determine if the human or computer wins:
  const humanIsWinner = compareGuesses(currentHumanGuess, computerGuess, target)
  const winner = humanIsWinner ? 'human' : 'computer'

Is this code doing what the project is asking me to do? Is the game.js the “solution code”?

If not, it seems almost harder to “see” the entire code because I feel like I’m only coding half of it. For example, I was going to write code to generate the computer’s guess, but the game.js contains the code const computerGuess = Math.floor(Math.random() * 10);

So I’m guessing I don’t need to do that. Is there a link to a video if (when) I get stuck to walk me through it? Thanks

1 Like

Hello, @object0257697420.

No. You are asked to write four functions. The code in the game.js file will call your functions when they are needed.

No. The four functions you are asked to write are not included in the game.js file.

That’s essentially it. The game.js file contains the bulk of the code necessary to play the game. The four functions you are asked to write are essential to playing the game, and will be called when needed by code in the game.js file.

1 Like