First and foremost, it's important to note that in JavaScript there is no explicit 2D array data structure. What you typically refer to as a 2D array is essentially an array of arrays.
For instance, you can create a 4x4 array like this:
>>> const array = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
]
>>> array[1][1]
6
In your scenario, you would need to initialize an empty multidimensional array and then populate it with values as needed.
A quick way to create a `10x10` array with `0` as the default value is:
>>> const a = new Array(10).fill(new Array(10).fill(0))
>>> a
(10) [Array(10), Array(10), Array(10), Array(10), Array(10), Array(10), Array(10), Array(10), Array(10), Array(10)]
0: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
1: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
3: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
4: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
5: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
7: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
8: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
9: (10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
length: 10
__proto__: Array(0)
Once you have your array set up, you can access and modify values using index notation:
a[9][9] = 10
10
a[9][9]
10