第一种方法可以正常使用:
var hash = "#";
for (hash.length = 1; hash.length <= 7; hash += "#"){
console.log(hash);
}
这种方法有些奇怪:
var line = "#";
for(i = 0; i <= 7; i++) {
while (line.length < i)
line =+ "#";
console.log(line);
}
答案 0 :(得分:1)
你转换了你的=和+它应该是:
var line = "#";
for(var i = 0; i <= 7; i++) {
while (line.length < i)
line += "#";
console.log(line);
}