Created
August 13, 2019 19:45
-
-
Save kdev/a62efbe93f48831462f368cc011a27a9 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
// define a Array | |
let array = ["String 1", "STRING 2", "String 3"]; | |
// defining a new function named getRandomIndex | |
let getRandomIndex = array => { | |
// get a random number between 0 and 1 and * by the array lenght | |
let rand = Math.floor(Math.random() * array.length); | |
// let the index is the random number from above | |
let randIndex = array[rand]; | |
// return the array item | |
return randIndex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment