Last active
March 23, 2021 18:28
-
-
Save bobdobbalina/803a2ad70bc18c1c08831b14eb800ac0 to your computer and use it in GitHub Desktop.
Javascript: Get random item from array
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
function random_item(items) { | |
return items[Math.floor(Math.random() * items.length)]; | |
} | |
const items = [254, 45, 212, 365, 2543]; | |
console.log(random_item(items)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment