Advertisement
Spocoman

07. NxN Matrix

Jan 28th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve (num) {
  2.    
  3.     function NxNMatrix() {
  4.         let print = '';
  5.         for (let i = 0; i < num; i++) {
  6.             for (let j = 0; j < num; j++) {
  7.                 print += num + ' ';
  8.             }
  9.             print += '\n';
  10.         }
  11.         return print;
  12.     }
  13.     console.log(NxNMatrix());
  14. }
  15.  
  16. Или :
  17.  
  18. function solve (num) {
  19.  
  20.     for (let i = 0; i < num; i++) {
  21.         console.log(`${num} `.repeat(num));
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement