loading...

Discussion on: Daily Challenge #169 - Christmas Tree

Collapse
savagepixie profile image
SavagePixie

In JavaScript

const christmasTree = height => {
  const width = height * 2 - 1
  return Array
    .from(
      { length: height },
      (v, i) => {
        const stars = i + 1
        return '*'.repeat(stars * 2 - 1)
          .padStart(width / 2 + stars)
          .padEnd(width)
      }
    )
    .join('\n')
}