Created
May 1, 2018 22:03
-
-
Save martinsson/67ca3b4cb1b611f0674e1d25c325535c to your computer and use it in GitHub Desktop.
Bug generator: Use of indices
This file contains hidden or 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
cardIndex = cardIndex + someStep | |
if (cardIndex > cards.length) { | |
cardIndex = 0 | |
} | |
let card = cards[cardIndex] | |
// Use of a modulo would be simpler and less error-prone. | |
cardIndex = (cardIndex + someIndex) % deckOfCards.length | |
let card = deckOfCards[cardIndex] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment