Skip to content

Instantly share code, notes, and snippets.

@wushan
Created February 22, 2017 15:23
Show Gist options
  • Save wushan/39f2731748838f024c1898a352e8c457 to your computer and use it in GitHub Desktop.
Save wushan/39f2731748838f024c1898a352e8c457 to your computer and use it in GitHub Desktop.
Javascript 考題 - 印出星星
var limit = 10
var row = []
for (var i = 0; i < limit; i++) {
row.length = 0
//Space
for (var space = 0; space < (limit - i); space++) {
row.push(' ')
}
for (var stars = 0; stars < i; stars++) {
row.push('*')
}
console.log(row.toString().replace(/,/g, ''))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment