This is my first question and I'll try to be clear.
I need to assign a value in positions. I have a two-dimensional array of 7 rows ( for example). Depending on the value someone give me, I have to change value positions.
Example If someone give me: 3. I must put these 3, in the following order.
1 * * * * * * * * * 
2 * * * * * * * * * 
3 * * * * * * * * O 
4 * * * * * * * * O 
5 * * * * * * * * O 
6 * * * * * * * * * 
7 * * * * * * * * * 
If some one give me: 2
1 * * * * * * * * * 
2 * * * * * * * * * 
3 * * * * * * * * O 
4 * * * * * * * * O 
5 * * * * * * * * * 
6 * * * * * * * * * 
7 * * * * * * * * * 
I define de some start point in the "middle" of the array. These i do OK. start point in the middle. S = Start point
1    * * * * * * * * * 
2    * * * * * * * * * 
3    * * * * * * * * * 
4    S * * * * * * * * 
5    * * * * * * * * * 
6    * * * * * * * * * 
7    * * * * * * * * * 
The problem is when i must put '0' in the final of the array, because the number of '0' is variable and must be centered I have these code:
var height = 7;
var width = 9;
var exit = 3; // or can be 2, or 4, 5 etc.
var matrix = new Array(height); 
for (var i=0; i<height; i++) { 
    matrix[i] = new Array(width); 
    for (var j = 0; j<width; j++) { 
        matrix[i][j] = *; 
    } 
}
function startPoint(height, matrix){
    // Se define el punto de partida
    var startPoint = Math.round(height/2) -1;
    document.write("el punto de partida es: "+startPoint)
    matrix[startPoint][0] = 'S';
    return matrix
}
function finishPoint(exit, matrix){
    // punto de salida.
    return matrix
}
I'm learning JavaScript and I found a problem that I can not resolv. I'm trying and I can not have a clear idea.
 
     
     
    