Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```js
- const orginal = [
- [a, b, c, d],
- [e, f, g, h],
- [i, j, k, l, e, h, j, i],
- [m, n, o, p],
- ]
- const randomItems = orginal.map((subArray) => {
- return mapFunc(subArray))
- }
- /// DEFINITIONS
- const mapFunc = (subArray) => {
- const randomIndex = randInt(subArray.length - 1)
- const randomSelection = subArray[randomIndex]
- return randomSelection
- }
- const randInt = (maximumNumber) => {
- return Math.floor(Math.random() * maximumNumber)
- }
- // NOTES
- 0 - 1
- 0.25
- >> [b,
- h,
- i,
- p]
- ```
Add Comment
Please, Sign In to add comment