Skip to content

Instantly share code, notes, and snippets.

@abhi9bakshi
Created October 1, 2019 11:13
Show Gist options
  • Save abhi9bakshi/93332235683a47c2d7fc16b25d158788 to your computer and use it in GitHub Desktop.
Save abhi9bakshi/93332235683a47c2d7fc16b25d158788 to your computer and use it in GitHub Desktop.
Generate Kite
__SIZE__ = 125;
function getKite(size) {
for(let i=0; i<size; i++){
let width = 0;
let str = '';
let symbol = '';
let space = 0;
// If less than or equal to half
if(i < Math.ceil(size/2)) {
width = i*2 + 1;
symbol = "*";
} else {
width = (size - i)*2 - 1;
symbol = "#";
}
space = (size - width)/2;
for(let j=1; j<=space; j++) {
str += " ";
}
for(let j=1; j<=width; j++) {
str += symbol;
}
console.log(str);
}
}
getKite(__SIZE__);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment