Javascript examples for Array Operation:Multi Dimensional Array
Filling up a 2D array with random numbers in javascript
<html> <head></head> <body> <script> debugger;/*from w w w.j av a 2 s.com*/ var ground = generateGround(10, 10); function generateGround(height, width) { var ground = []; for (var y = 0 ; y < height; y++) { ground[y] = []; for (var x = 0; x < width; x++) { ground[y][x] = my(); } } return ground; function my() { return (Math.random() * 5 | 0) + 6; } } </script> </body> </html>