Advertisement
Spocoman

06. Rhombus of Stars

Jan 3rd, 2022
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(number) {
  2.  
  3.     for (let i = 1; i <= number; i++) {
  4.         let currentRow = '';
  5.         for (let j = 0; j < number - i; j++) {
  6.             currentRow += ' ';
  7.         }
  8.         for (let k = 0; k < i; k++) {
  9.             currentRow += '* ';
  10.         }
  11.         console.log(currentRow);
  12.     }
  13.  
  14.     for (let i = number - 1; i > 0; i--) {
  15.         let currentRow = '';
  16.         for (let j = number - i; j > 0; j--) {
  17.             currentRow += ' ';
  18.         }
  19.         for (let k = 0; k < i; k++) {
  20.             currentRow += '* ';
  21.         }
  22.         console.log(currentRow);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement