-3
function printFarmInventory(monkeys, cats) {
var monkeystring = String(monkeys);
while (monkeystring.length < 3) {
monkeystring = "0" + monkeystring;
}
console.log(monkeystring + "nice");
var catstring = String(cat);
while (catstring.length < 3) {
chimpstring = "00" + catstring;
}
console.log(catstring + "great");
}
printFarmInventory(4, 7);
什么'cat'在'字符串(CAT);'?我也感觉到了一个无限循环。 – j08691
错误信息会告诉你你想要引用的内容。检查变量名称并确定它是你定义的。寻找错别字。 (Typo很明显,投票结束,作为题外话) – Quentin
'chimpstring'从哪里来? – evolutionxbox