Skip to content Skip to sidebar Skip to footer

Creating A Multidimensional Array (nxn) Matrix Using Javascript

I am trying to create a matrix table. The values to be plugged into the matrix will be user input from an html table (basically a unique pairing table which pairs two elements at a

Solution 1:

You can push a value to an array, for example:

var a = [];
a.push(1);
a.push(2);
console.log(a); // [1, 2]

You can set it based on index:

var a = [];
a[0] = 1;
a[1] = 2;
console.log(a); // [1, 2]

To create a multi dimensional array you can simply push arrays to one array.

var a = [1,2,3];
var b = [4,5,6];
var c = [];
c.push(a);
c.push(b);
console.log(c); // [[1, 2, 3], [4, 5, 6]]

Solution 2:

I think you are trying to implement the AHP algorithm here. It is quite complex to write the whole code here and how it'll work but here is a link of an already exiting work on AHP. Hope it helps: https://github.com/humbertoroa/ahp

Post a Comment for "Creating A Multidimensional Array (nxn) Matrix Using Javascript"