Skip to content

Instantly share code, notes, and snippets.

@ianhoffman
Created April 25, 2020 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianhoffman/2b19dc7596b6e981add8f8acf5ba634d to your computer and use it in GitHub Desktop.
Save ianhoffman/2b19dc7596b6e981add8f8acf5ba634d to your computer and use it in GitHub Desktop.
Maybe inserting into an array
userGuess = 'a' // Whatever
userGuesses = [] // Assume this is populated
shouldInsertGuess = true;
for (var i = 0; i < userGuesses.length; i++) {
if (userGuesseses[i] === userGuess) {
shouldInsertGuess = false;
break;
}
}
if (shouldInsertGuess) {
userGuesses.push(userGuess)
}
// Carry on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment