Created
May 24, 2021 17:49
-
-
Save naxmefy/65b5dd81186245a2885dda755f7a41f6 to your computer and use it in GitHub Desktop.
print a diamond with n size
This file contains 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 = parseInt(readline()); | |
console.log("#".repeat(N)); | |
for(var i = 1; i < (N * 2); i+=2){ | |
console.log(" ".repeat((N*2 - i) / 2) + "#".repeat(i)); | |
} | |
for(var i = N * 2 - 1; i > 0; i-=2){ | |
console.log(" ".repeat((N*2 - i) / 2) + "#".repeat(i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment