Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dataArr = [
- [1, 2, 3],
- [4, 5, 6],
- [9, 8, 9],
- ];
- let diag1 = 0;
- for (let i = 0; i < dataArr.length; i++) {
- for (let j = 0; j < dataArr.length; j++) {
- if (i === j) {
- diag1 += dataArr[i][j];
- }
- if (i + j === dataArr.length - 1) {
- diag2 += dataArr[i][j];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement