How to print the following Multi-Dimensional array in JavaScript?

后端 未结 5 1078
醉酒成梦
醉酒成梦 2021-01-05 01:49

I have the following array (the code is written in Java) :

String[][] a = new String[3][2];
a[0][0] = \"1\"; 
a[0][1] = \"2\"; 

a[1][0] = \"1\";  
a[1][1]          


        
5条回答
  •  醉话见心
    2021-01-05 02:14

    for (i=0; i < a.length; i++) {
       for (j = 0; j < a[i].length; j++) { document.write(a[i][j]); }
    }
    

    Though it would be smarter to add all the strings together and the print them out as one (could add to an element or alert it out.)

提交回复
热议问题