# Thread: [RESOLVED] Help - Begginer - Problem with matrix

1. Registered User
Join Date
May 2014
Posts
2

## [RESOLVED] Help - Begginer - Problem with matrix

The code just keep giving me 6 or 8 independent of the position i'm trying to access.

Code:
```var valueMatrix = 0;
var matrix = [[0,0],[0,0],[0,0]];
matrix[0,0,0] = 1;
matrix[0,1,0] = 2;
matrix[0,0,1] = 3;
matrix[0,1,1] = 4;
matrix[1,0,0] = 5;
matrix[1,1,0] = 6;
matrix[1,0,1] = 7;
matrix[1,1,1] = 8;

function test()
{
valueMatrix = matrix[0,0,0];
}```

I dont know how to solve this...

(sorry for my poor english)

2. It looks like you're trying to work with a multi-dimensional array, in which case I believe what you want is:
Code:
```var valueMatrix = 0;
var matrix = [[[]], [[]], [[]]];
matrix[0][0][0] = 1;
matrix[0][1][0] = 2;
matrix[0][0][1] = 3;
matrix[0][1][1] = 4;
matrix[1][0][0] = 5;
matrix[1][1][0] = 6;
matrix[1][0][1] = 7;
matrix[1][1][1] = 8;

function test() {
valueMatrix = matrix[0][0][0];
console.log(valueMatrix);
}```

3. Registered User
Join Date
May 2014
Posts
2
Yeah! It worked!

Thanks for the support!