Skip to content

Instantly share code, notes, and snippets.

@shannonjen
Created January 18, 2018 11:08
Show Gist options
  • Save shannonjen/70b9fbd638986a6c1d3dfb71de3917e7 to your computer and use it in GitHub Desktop.
Save shannonjen/70b9fbd638986a6c1d3dfb71de3917e7 to your computer and use it in GitHub Desktop.
g65 Warm Up, 1/18
// Create a function that receives a (square) matrix and calculates the sum of both diagonals (main and secondary)
// Matrix = array of n length whose elements are n length arrays of integers.
// 3x3 example:
// diagonals( [
// [ 1, 2, 3 ],
// [ 4, 5, 6 ],
// [ 7, 8, 9 ]
// ] );
// returns -> 30 // 1 + 5 + 9 + 3 + 5 + 7
function diagonals() {
//Solution here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment