My task involves an array of numbers ranging from 1 to 60.
var originalArray = [1, 2, 3, 4 .... 58, 59, 60] // etc
The challenge is to split these numbers randomly into a specified number of arrays based on another number between 2 and 4. It is important for the outcome to be unique each time.
For instance:
distributeArray(2)
should produce two arrays, each containing 30 randomly selected numbers from the original array.
distributeArray(3)
should yield three arrays, each with 20 numbers chosen randomly from the original array.
This scenario may be common, so any advice or guidance would be greatly appreciated. Thank you in advance.