Skip to content

Instantly share code, notes, and snippets.

@kerrishotts
Last active August 31, 2019 12:08
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 kerrishotts/397c1c000655a4e9007326de6e4d54a4 to your computer and use it in GitHub Desktop.
Save kerrishotts/397c1c000655a4e9007326de6e4d54a4 to your computer and use it in GitHub Desktop.
Dev.to Challenge # 52
const PYRAMID = "*";
const AIR = "·";
const pyramid = (n, {maxWidth = (n * 2) - 1, leftPadding = maxWidth / 2} = {}) =>
Array.from({length: n}, (_, idx, __, {width = (( idx + 1 ) * 2) - 1} = {}) =>
PYRAMID.repeat(width)
.padStart(idx + leftPadding + 1, AIR)
.padEnd(maxWidth, AIR)
).join("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment