JavaScript 2D Materials Array

I have a JS that picks a random material from a built-in Array of 10 different materials every 5’’ and assigns it to a gameObject. I want the materials that make up the Array, to have different possibilities of being selected and was thinking of doing something in this logic, only in JavaScript (make a 2d array, where the first column is a material and the second is how many times this material appears).

I read in Eric’s JavaScriptMultiDimArrays article that “now you can use the MultiDim class and type inference to declare rectangular 2D and 3D arrays of ints, floats, and strings”.

So this means that I cannot make a 2D built-in Array that contains materials and their occurrence?

There is a library in this thread that contains functions for various random picking and shuffling tasks. It contains a function for picking items randomly but with differently probabilities of being chosen. There is also a class that can perform this task very quickly when the number of options is large.

Thank you very much andeeee. From what I read in the attached doc, it seems to be the best tool that one could think of, for handling these tasks. The vast majority of games could use it.