- 1
10. Write a JavaScript function which returns the n rows by n columns identity matrix.
10. Write a JavaScript function which returns the n rows by n columns identity matrix.
1 Respuesta
0
<script>
function myFunc(n) {
"use strict";
var arr = [], i, j;
for (i = 0; i < n; i += 1) {
arr[i] = [];
for (j = 0; j < n; j += 1) {
arr[i][j] = {i: i, j: j};
}
}
return arr;
}
</script>