Last active
December 15, 2022 19:54
-
-
Save briyithhhh/7749ee56418347f3f937d7df517471f9 to your computer and use it in GitHub Desktop.
diamond-pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const n = 5 | |
| for (let i = 1; i <= n; i++){ | |
| for(let j = 1; j <= n - i; j++){ | |
| process.stdout.write(' ') | |
| } | |
| for(let k = 0; k < 2 * i - 1; k++){ | |
| process.stdout.write('*') | |
| } | |
| console.log() | |
| } | |
| for (let i = 1; i <= n - 1; i++){ | |
| for(let j = 0; j < i; j++){ | |
| process.stdout.write(' ') | |
| } | |
| for(let k = (n - i) * 2 - 1; k > 0; k--){ | |
| process.stdout.write('*') | |
| } | |
| console.log() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment