Advertisement
RokiAdhytama

Init Array 3 - Chapter 11

Jul 3rd, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <html xmlns = "http://www.w3.org/1999/xhtml">
  2. <head>
  3. <title>Initializing Multidimensional Arrays</title>
  4.  
  5. <script type = "text/javascript">
  6. <!--
  7. function start()
  8. {
  9. var array1 = [ [ 1, 2, 3 ], // first row
  10. [ 4, 5, 6 ] ]; // second row
  11. var array2 = [ [ 1, 2 ], // first row
  12. [ 3 ], // second row
  13. [ 4, 5, 6 ] ]; // third row
  14.  
  15. outputArray( "Values in array1 by row", array1 );
  16. outputArray( "Values in array2 by row", array2 );
  17. }
  18.  
  19. function outputArray( header, theArray )
  20. {
  21. document.writeln( "<h2>" + header + "</h2><tt>" );
  22.  
  23. for ( var i in theArray ) {
  24.  
  25. for ( var j in theArray[ i ] )
  26. document.write( theArray[ i ][ j ] + " " );
  27.  
  28. document.writeln( "<br />" );
  29. }
  30.  
  31. document.writeln( "</tt>" );
  32. }
  33. // -->
  34. </script>
  35.  
  36. </head><body onload = "start()"></body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement