-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