Created
February 22, 2017 15:23
-
-
Save wushan/39f2731748838f024c1898a352e8c457 to your computer and use it in GitHub Desktop.
Javascript 考題 - 印出星星
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 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