我想打印一个字符串,例如: blah
3次,但我想链接该函数的字符串。将函数链接到要打印的字符串
我现在就做,像这样:
function repeatMe(number) {
for (var i = 0; i < number; i++) {
document.write('blah');
}
}
console.log(repeatMe(3));
但它有可能调用函数打印blah
像这样:
console.log('blah'.repeatMe(3));
注意'repeatMe'应*返回一个字符串*,不打印。该函数不被称为'printMeTimes'左右。你想叫它像'document.write(repeatMe('blah',3))',*或*'console.log',或者... – Bergi 2014-12-03 11:46:20
不要使用'document.write'。 – Andy 2014-12-03 11:48:19