Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. ```js
  2.  
  3. const orginal = [
  4. [a, b, c, d],
  5. [e, f, g, h],
  6. [i, j, k, l, e, h, j, i],
  7. [m, n, o, p],
  8. ]
  9.  
  10. const randomItems = orginal.map((subArray) => {
  11. return mapFunc(subArray))
  12. }
  13.  
  14.  
  15. /// DEFINITIONS
  16.  
  17. const mapFunc = (subArray) => {
  18. const randomIndex = randInt(subArray.length - 1)
  19. const randomSelection = subArray[randomIndex]
  20. return randomSelection
  21. }
  22.  
  23. const randInt = (maximumNumber) => {
  24. return Math.floor(Math.random() * maximumNumber)
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. // NOTES
  33.  
  34. 0 - 1
  35.  
  36. 0.25
  37.  
  38. >> [b,
  39. h,
  40. i,
  41. p]
  42.  
  43.  
  44.  
  45.  
  46.  
  47. ```
Add Comment
Please, Sign In to add comment