Skip to content

Instantly share code, notes, and snippets.

@mateja176
Last active April 13, 2024 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateja176/7e19066b8532bbeb81c1587b0dc5641f to your computer and use it in GitHub Desktop.
Save mateja176/7e19066b8532bbeb81c1587b0dc5641f to your computer and use it in GitHub Desktop.
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