Created
April 25, 2018 23:13
-
-
Save cvan/2616e33aa84b9221d996622a2c710139 to your computer and use it in GitHub Desktop.
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
_getRandomEnvironment = environments => { | |
const randomEnvironmentIndex = () => Math.floor(Math.random() * environments.length); | |
let newEnvironmentIndex = randomEnvironmentIndex(); | |
if (this.state && this.state.hasOwnProperty('environmentIndex') && environments.length > 1) { | |
while (newEnvironmentIndex === this.state.environmentIndex) { | |
newEnvironmentIndex = randomEnvironmentIndex(); | |
} | |
} | |
return newEnvironmentIndex; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment