Skip to content

Instantly share code, notes, and snippets.

@micahwierenga
Last active April 30, 2020 17:33
Show Gist options
  • Save micahwierenga/c1348c18464a9c8e625ef7d37cb19952 to your computer and use it in GitHub Desktop.
Save micahwierenga/c1348c18464a9c8e625ef7d37cb19952 to your computer and use it in GitHub Desktop.

Guess the Numbers Lab Pseudocode

const game = {
  title: 'Guess the Number!',
  biggestNum: 100,
  smallestNum: 1,
  secretNum: null,
  prevGuesses: [],
  play: function() {
    this.secretNum = Math.floor(Math.random() * 
      (this.biggestNum - this.smallestNum + 1)) + this.smallestNum;
    // Create a current guess variable but doesn't have a real value yet
    // Keep calling getGuess with a while loop (the loop should continue running as long as the current guess doesn't equal the secretNum)
      // Give the current guess a value, which is the calling of getGuess
      // Take that current guess and put it in prevGuesses
      // Call render and pass it the current guess
  },
  getGuess: function() {
    // Create a variable for the current guess
    // Keep prompting the user for a guess until their guess is a number and it's less than the biggestNum and it's greater than the smallestNum
      // Give the current guess variable a value of the prompt
    // return the current guess variable
  },
  render: function (guess) {
    // if the user guessed correctly
      // give them an alert with the secretNum that they guessed correctly, along with the number of guesses it took
    // else if their guess was higher than the secretNum
      // give them an alert that contains a message that it's higher, as well the guesses they've already made
    // else if their guess was lower than the secretNum
      // give them an alert that contains a message that it's lower, as well the guesses they've already made
  }
};


game.play();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment