Hi i want to generate a grid of random numbers and operators both vertical and horizontal using 2D array in javascript. how can i do it?

I didn't understand the part about operators, pardon my bad english.
but i think something like this should do it for 2d arrays of random numbers:

var x = [];
var y = [];

for(var i=0; i<10; i++)
{
    for(var m=0; m<10; m++)
        {
            y[m]= Math.random()*100; //0~100
        }
    x[i]=y;
}

Here is another way to create a (square) 2D array in Javascript:

var MATRIXDIM = 5;  // Dimension of a square matrix
var A = new Array(MATRIXDIM); 

for (var i = 0; i < MATRIXDIM; i++){ // Create the square Matrix
   A[i] = new Array(MATRIXDIM);
} // End for i loop

At this point, a square 5 x 5 matrix named A has been created. Now to assign data to the array, you do something like this:

A[1][2] = 25;

This assigns the number 25 to the array element in row 2, column 3 (remember, array indexing in Javascript starts at 0).

How are you getting the data in the first place? Several textboxes? A textarea box? etc.?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.