Last active
November 27, 2022 18:21
-
-
Save ulvimammaadov/07f2c44357df3eed959ad66066a0bd84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [ | |
[1, 2, 3], | |
[4, 5, 6], | |
[9, 8, 9], | |
]; | |
let firstSum = 0,secondSum = 0; | |
for (let i = 0; i < arr.length; i++) { | |
firstSum +=arr[i][i]; | |
} | |
let j = 0; | |
for (let i = arr.length-1; i >= 0; i--) { | |
secondSum += arr[i][j]; | |
j++; | |
} | |
console.log(Math.abs(firstSum-secondSum)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment