Skip to content

Instantly share code, notes, and snippets.

@ulvimammaadov
Last active November 27, 2022 18:21
Show Gist options
  • Save ulvimammaadov/07f2c44357df3eed959ad66066a0bd84 to your computer and use it in GitHub Desktop.
Save ulvimammaadov/07f2c44357df3eed959ad66066a0bd84 to your computer and use it in GitHub Desktop.
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