-2
我正在處理一個簡單的問題,即輸入橘子的價格和購買桔子的數量並計算總成本。 請檢查這段代碼,讓我知道我要去哪裏錯了。用我的Javascript功能發出問題
var numberofOranges;
var costofOrange;
var orangeCost = function (costofOrange, numberofOranges) {
var Cost = costofOrange * numberofOranges;
return Cost;
};
confirm ("Confirm Number of Oranges you are buying", numberofOranges, costofOrange);
if ((numberofOranges === > 0 && typeof(numberofOranges)!= "string") && (costofOranges === > 0 && typeof(costofOranges)!= "string")) {
console.log("Cost of" + numberofOranges + "Oranges is" + (orangeCost(numberofOranges));
}
else {
console.log("Enter valid input");
}
用'console.log(變量)'註銷變量並找出你自己。 – ceejayoz
對於初學者來說,這不是'confirm()'的工作方式。 https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm – ceejayoz
orangeCost函數下面的所有內容都是錯誤的。確認不是像這樣工作和「===」這不是一件事情,orangeCost用於一個參數,但你需要其中的2個,你需要像這樣使用orangeCost(5,20); - 5美元和20個桔子。也有人停止投票,很明顯,他試過這不是從谷歌複製粘貼! –