javascript – Filling 2D array with a MIDI pattern

I am struggling with a simple fill of 2D array, following a pattern given by MIDI notes list Midi Notes Array. Basically, what I need to do is to fill a full width and hight of a canvas with numbers from 0 – 127.

I know that the logic is flawed, but I can’t figure out how to solve it.

  let m = 0
  let n = 0;
  let blockW = Math.floor(width/12)
  let blockH = Math.floor(height/10)

   for (var i = 0; i < 12; i++) {
        for (var j = 0; j < 10; j++) {
            for (var x = blockW * m; x < blockW *(m+1); x++) {
                midiArray[x] = []
                for (var y = blockW * m; y < blockW *(m+1); y++) {
                    midiArray[x][y] = n          
                }  
            }   
     
        }
        m++  
        n++     
    }

Any help would be appreciated !

Read more here: Source link