Created
July 3, 2023 16:43
-
-
Save kironroy/fc3dc2ae593ebd16823224cfe012d4ef to your computer and use it in GitHub Desktop.
random js 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
// try 100 random dice rolls | |
// create array of 100 numbers (1 to 100) | |
const diceRollsArr = Array.from({length: 100}, (_, i) => i + 1); | |
console.log(Array.isArray(diceRollsArr)); | |
// sort array (random) | |
const rdmDiceRollsArr = diceRollsArr.sort((a, b) => 0.5 - Math.random()); | |
console.log(diceRollsArr); | |
console.log('----'); | |
console.log(rdmDiceRollsArr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment