Advertisement
Spocoman

Perfect Diamond

Oct 1st, 2023 (edited)
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function perfectDiamond(input) {
  2.     let n = Number(input);
  3.  
  4.    for (let i = 0; i <n; i++) {
  5.     console.log(" ".repeat(n - (i + 1)) + '*' + "-*".repeat(i));
  6.     }
  7.  
  8.     for (let i = n - 2; i >= 0; i--) {
  9.         console.log(" ".repeat(n - (i + 1)) + '*' + "-*".repeat(i));
  10.     }
  11.  
  12.     return;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement