Create a function christmasTree(height)
or christmas_tree(height)
(in Ruby) that returns a Christmas tree of the correct height
christmasTree(5)
|| christmas_tree(height)
should return:
Height passed is always an integer between 0 and 100.
Use \n for newlines between each line.
Pad with spaces so each line is the same length. The last line having only stars, no spaces.
This challenge comes from user8062788 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (4)
In Python:
Demo:
In JavaScript
Forgot to post my soution from yesterday, also in Python: