Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <script>
- function det(m) // calculate the determinant of the square matrix m
- {
- if (m.length === 2) // if its a 2X2 matrix..
- return m[0][0] * m[1][1] - m[0][1] * m[1][0];
- }
- var matrix = [[1, 2], [3, 4]];
- document.write(det(matrix));// -2
- </script>
- <head>
- <title>Matrix</title>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment