waltermilner

Untitled

Mar 23rd, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4.   <script>
  5.     function det(m) // calculate the determinant of the square matrix m
  6.     {
  7.         if (m.length === 2) // if its a 2X2 matrix..
  8.             return m[0][0] * m[1][1] - m[0][1] * m[1][0];
  9.     }
  10.  
  11.     var matrix = [[1, 2], [3, 4]];
  12.     document.write(det(matrix));// -2
  13.   </script>
  14.   <head>
  15.     <title>Matrix</title>
  16.   </head>
  17.   <body>
  18.   </body>
  19. </html>
Advertisement
Add Comment
Please, Sign In to add comment