问答详情
源自:3-7 二维数组

如果我只想输出一组二维数组的值怎么写啊,求解

例如我只想输出myarr[1][1]的值怎么写啊?下面这样写出不来~求帮助,谢谢啦


<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>二维数组</title>
<script type="text/javascript">
var myarr=new Array();
for(var i=0;i<3;i++){
    myarr[i]=new Array();
    for(var j=0;j<5;j++){
        myarr[i][j]=i+j;
   
        document.write(myarr[1][1]);
    }
}
</script>
</head>

<body>
</body>
</html>

提问者:慕粉3815227 2018-06-24 17:19

个回答

  • 慕丝4347042
    2018-06-24 22:07:25
    已采纳

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>二维数组</title>

    <script type="text/javascript">

    var myarr=new Array();

    for(var i=0;i<3;i++){

        myarr[i]=new Array();

        for(var j=0;j<5;j++){

            myarr[i][j]=i+j;        

        }

    }

      document.write(myarr[1][1]);

    </script>

    </head>

    <body>

    </body>

    </html>


  • 慕爱好者
    2018-07-17 17:58:32

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>二维数组</title>
    <script type="text/javascript">
    var myarr=new Array();
    for(var i=0;i<3;i++){
        myarr[i]=new Array();
        for(var j=0;j<6;j++){
            myarr[i][j]=i*j;
          document.write("数组的值myarr"+"["+i+"]"+"["+j+"]="+myarr[i][j]+"<br/>");
        }
    }

    </script>
    </head>

    <body>
    </body>
    </html>

  • 慕斯卡6904759
    2018-06-25 11:44:25

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>二维数组</title>

    <script type="text/javascript">

    var myarr=new Array();

    for(var i=0;i<3;i++){

        myarr[i]=new Array();

        for(var j=0;j<5;j++){

            myarr[i][j]=i+j;        

        }

    }

      document.write(myarr[1][1]);

    </script>

    </head>

    <body>

    </body>

    </html>