Skip to content

Instantly share code, notes, and snippets.

@gunharth
Last active November 6, 2020 20:56
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 gunharth/402981678d2fee6efa5bcf795a7c27ff to your computer and use it in GitHub Desktop.
Save gunharth/402981678d2fee6efa5bcf795a7c27ff to your computer and use it in GitHub Desktop.
JS Recursion 1/2 Pyramid
//let stackCount = 0; // show stack sequence
let height = 4;
draw(height)
function draw(h) {
if (h === 0) {
return;
}
//stackCount = h -1
// console.log(stackCount)
draw(h - 1)
//console.log('run stack ' +h)
let str = ""
for (let i = 0; i < h; i++) {
str += '#'
}
console.log(str)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment