Created
April 25, 2020 00:38
-
-
Save ianhoffman/2b19dc7596b6e981add8f8acf5ba634d to your computer and use it in GitHub Desktop.
Maybe inserting into an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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