title: How to input numbers by keyboard in js matrices
body: <p>I stuck with my program. I have to make a matrix and enter a value of every cell, then calculate the sum of the elements of the two main diagonals of the matrix. 
  1st problem - I can't find solution how to make matrix with elements that I enter by keyboard.</p>
  
  <pre><code>&lt;meta charset="windows-1251"&gt;
  &lt;script&gt;
      //10. A real square matrix of size n x n. Calculate the sum of the elements of the two main diagonals of the matrix.
      var r,c; //r - rows, c - columns
      r = prompt('Enter the number of rows');
      c = prompt('Enter the number of columns');
      var mat = [];
          for (var i=0; i&lt;r; i++){
              mat[i] = [];
          }
              for (var j=0; j&lt;c; j++){
                  mat[i][j]= prompt ('Enter a value for the cell ' + i + 'x' + j)
  
              }
  
      document.write(' &lt;XMP&gt; ');
      document.write('Matrix \t' + mat + '\r');
      document.write('&lt;/XMP&gt;');
  
  &lt;/script&gt;
  </code></pre>