Last active
April 13, 2024 11:28
-
-
Save mateja176/7e19066b8532bbeb81c1587b0dc5641f to your computer and use it in GitHub Desktop.
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
function christmasTree(n: number) { | |
let padding = n - 1; | |
for (let index = 1; index < n; index++) { | |
const oddNumber = index * 2 - 1; | |
console.log(' '.repeat(padding), '*'.repeat(oddNumber)); | |
padding -= 1; | |
} | |
} | |
christmasTree(4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment