Created
October 1, 2019 11:13
-
-
Save abhi9bakshi/93332235683a47c2d7fc16b25d158788 to your computer and use it in GitHub Desktop.
Generate Kite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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