var matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; var SOD = 0; var SAD = 0; var SUD = 0; for (var i=0; i<matrix.length; i++) { for (var j=0; j<matrix[i].length; j++) { if (i == j) { SOD = SOD + matrix[i][j]; } else if (i < j) { SAD = SAD + matrix[i][j]; } else if (i > j) { SUD = SUD + matrix[i][j]; } } } write("Sum of elements above the diagonal = " + SAD + "\n"); write("Sum of elements under the diagonal = " + SUD + "\n"); write("Sum of elements on the diagonal = " + SOD);
(
)
{
}
[
]
"
;
=
+
-
*
!
/
%
&
|