Skip to content

Instantly share code, notes, and snippets.

@briyithhhh
Last active December 15, 2022 19:54
Show Gist options
  • Select an option

  • Save briyithhhh/7749ee56418347f3f937d7df517471f9 to your computer and use it in GitHub Desktop.

Select an option

Save briyithhhh/7749ee56418347f3f937d7df517471f9 to your computer and use it in GitHub Desktop.
diamond-pattern
const n = 5
for (let i = 1; i <= n; i++){
for(let j = 1; j <= n - i; j++){
process.stdout.write(' ')
}
for(let k = 0; k < 2 * i - 1; k++){
process.stdout.write('*')
}
console.log()
}
for (let i = 1; i <= n - 1; i++){
for(let j = 0; j < i; j++){
process.stdout.write(' ')
}
for(let k = (n - i) * 2 - 1; k > 0; k--){
process.stdout.write('*')
}
console.log()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment