Created
September 14, 2016 07:20
-
-
Save igez/a48277187916e056751768d6ca1824e8 to your computer and use it in GitHub Desktop.
Hourglass without loop
This file contains 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
var temp = 0; | |
function draw(max) { | |
if (temp >= max * 2) return; | |
temp = temp + 2; | |
if (temp <= max && temp != max*2) ast(max - temp, '', max); | |
else if (temp >= max && temp != max*2) ast(temp - max, '', max); | |
} | |
function ast(col, string, max) { | |
if (string.length > col) { | |
console.log(Array((max - col)/2).join(' ') + string); | |
return draw(max); | |
} else ast(col, string += '*', max); | |
} | |
draw(26); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment