Skip to content

Instantly share code, notes, and snippets.

@igez
Created September 14, 2016 07:20
Show Gist options
  • Save igez/a48277187916e056751768d6ca1824e8 to your computer and use it in GitHub Desktop.
Save igez/a48277187916e056751768d6ca1824e8 to your computer and use it in GitHub Desktop.
Hourglass without loop
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