Skip to content

Instantly share code, notes, and snippets.

@fariswd
Created August 20, 2020 13:37
Show Gist options
  • Save fariswd/0a4c71561b86ce5f77fc417baffb2b93 to your computer and use it in GitHub Desktop.
Save fariswd/0a4c71561b86ce5f77fc417baffb2b93 to your computer and use it in GitHub Desktop.
star
for (let i = 0; i <= 20; i++) {
let log = ''
if (i > 10) {
for (let j = 10; j <= 20; j++) {
if (i > j) {
log += ' '
} else {
log += '*'
}
}
for (let k = i; k < 20; k++) {
log += '*'
}
} else {
for (let k = 0; k <= 10; k++) {
if (10 - i > k) {
log += ' '
} else {
log += '*'
}
}
for (let j = 0; j <= 10; j++) {
if (i > j) {
log += '*'
} else {
log += ' '
}
}
}
console.log(log)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment