JSFiddle - React, Tailwind, and code Playground
by kkdaily
HTML
<p><a href="https://jsfiddle.net/kkdaily/h5z81ac0/" target="_blank">Sort</a></p>
<p><a href="https://jsfiddle.net/kkdaily/upf4atow/" target="_blank">Colors</a></p>
JavaScript
/* write a program that takes an ixj matrix, and returns the sum of the diagonal of the matrix.
The diagonal will always go from left to right, top to bottom. Where this diagonal starts is
determined by a number. If the number is 0, you will start from the first element in the first
row. If the number is 1, you will start from the 2nd element in the first row, etc. If the number
is -1, you will start from the first element of the 2nd row. If the number is -2, you will start
from the 1st element of the 3rd row, etc */
var matrix = [[0, 1, 2], [3, 4, 5], [6, 7, 8]];
var num = 1;