Skip to content

Instantly share code, notes, and snippets.

@sairion
Last active April 10, 2017 04:43
Show Gist options
  • Save sairion/84f9debba1ac85099abe7ae4c427f045 to your computer and use it in GitHub Desktop.
Save sairion/84f9debba1ac85099abe7ae4c427f045 to your computer and use it in GitHub Desktop.
function range(limit) {
return Array.from(Array(limit)).map((_,i) => i)
}
function piramid(height = 10) {
return range(height).reduce((ret, i) => {
let space = ' '.repeat(height - i)
let slope = '*'.repeat(i)
return ret + `${space}${slope}*${slope}${space}\n`
}, '\n')
}
for (let i = 1; i < 10; i++) {
console.log(piramid(i))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment