0

I have to make a dynamic graph in asp.net. for this i need this type of data structure:- [[0, 0, 8], [0, 1, 2], [0, 2, 7] array inside array ,

i have used array.push ,but that convert my data set into this format:

 'for (var i = 0; i < forth.length; i++)
      {
         result.push([present2[i], present1[i], present3[i]]);
      }
  [0, 0, 8, 0, 1, 2, 0, 2, 7].'

I have 3 set of array: present2,present1,present3 'present2:-[0,1,2,3,4,5] present1:-[0,1,2,0,1,2] present3:-[8,2,7,1,4,2]'

now i want to create this type of structure using them '[[0, 0, 8], [0, 1, 2], [0, 2, 7]]' How can i do this?

2 Answers 2

1

var present2=[0,1,2,3,4,5], present1=[0,1,2,0,1,2] ,present3=[8,2,7,1,4,2];
var result=[];
for (var i = 0; i < present2.length; i++)
{
   result.push([present2[i], present1[i], present3[i]]);
}
console.log(result);

document.getElementById("output").innerHTML=JSON.stringify(result);
<div id="output"></div>

Sign up to request clarification or add additional context in comments.

Comments

0

Your code looks correct, more or less. Where is result defined?

This works:

  var result = [];

  for (var i = 0; i < forth.length; i++)
  {
     result.push([present2[i], present1[i], present3[i]]);
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.