Skip to content

Instantly share code, notes, and snippets.

@JoeKarlsson
Last active December 26, 2015 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save JoeKarlsson/27011b72338ff9aee901 to your computer and use it in GitHub Desktop.
Save JoeKarlsson/27011b72338ff9aee901 to your computer and use it in GitHub Desktop.

##The Challenge

Write a function that prints a nice Christmas tree of any size to the DOM with it's own star at the top using the shortest code possible. The tree star is an asterisk (*), the tree body is made out of 0 The tree must be at least 10 rows high, and at the bottom of the tree should be a trunk made of 2 pipe characters (|). Every row should be properly indented in the way that the previous row are centered over the next one. Any given row must have 2 more 0s than the previous, except for the first one that is the star and the second, which has only one 0. The result is something like this:

          *
          0
         000
        00000
       0000000
      000000000
     00000000000
    0000000000000
   000000000000000
  00000000000000000
          ||

Additional Requirements

  • Create a Git Repository for this challenge
    • commit often and have your commit messages be descriptive
  • Bonus points if you can do this recursivly.
  • After you have finished writing your function - make it festive by styling it!
  • Write tests for your function using the Mocha and Chai Libraries.
    • Provide test for all cases. Handle unexpected inputs, invalid arguments, etc.

'Christmas Tree'

Thaaaaaaanks :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment