need help on completing a guessing game in javascript [closed]

making a guessing game, and I need help on making my guessing game have a limited number of guesses, and for it to display the amount of guesses remaining left after each guess made by the user.

I tried to create an else if statement to do this, but it doesn’t seem to work.

function main() {
  const minNum = 0;
  const maxNum = 100;
  const answer = Math.floor(Math.random() * (maxNum - minNum + 1));
  let attempts = 0;
  let inGame = true;
  let guess;

  while (inGame) {
    guess = readInt("guess a number between 1 and 100: ");

    if (guess == answer) {
      inGame = false;
      console.log("you have successfully found the number");
    } else if (guess < answer) {
      inGame = true;
      console.log("your guess is too low");
    } else if (guess > answer) {
      inGame = true;
      console.log("your guess is too high");
    } else if (guess == 7) {
      inGame = false;
      console.log("you have failed the guess the number");
    }
  }
}
main();