Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function matrix(num) {
- let array = []; // we create a new empty array;
- for(let index = 0; index < num; index++) {
- array.push(num); // we create a For cycle which pushes the inputed number on every rotation to the empty array;
- }
- array = array.join(" "); // we convert the array to a string;
- for(let currentColumn = 1; currentColumn <= num; currentColumn++) {
- console.log(array); // on every column we print the array;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement