Last active
February 26, 2024 17:43
-
-
Save mcsee/c8fcd38572bce8e59bf28ceaede7a055 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 drawChristmasTree(height) { | |
let tree = ''; | |
let currentFloor = 1; | |
while (currentFloor <= height) { | |
tree += ' '.repeat(height - currentFloor) + '🎄'.repeat(currentFloor) | |
+ '\n'; | |
currentFloor++; | |
} | |
// This function has side effects | |
// You cannot test it | |
console.log(tree); | |
} | |
drawChristmasTree(7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment