我想讓用戶輸入一個數字,然後輸入另一個數字,該數字將開始輸入第一個數字的乘法表,並繼續遞增1,直到達到用戶提示的最後一個數字...Javascript函數問題
例如,如果用戶是要輸入10,則如圖1所示,然後如圖10所示,輸出將如下所示:
10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
...
10 * 10 = 100
我在做什麼錯?
感謝您的幫助!
function multiplierz(numberMultiplied, amountToMultiplyFirst, amountToMultiplyLast)
{
while (isNaN(numberMultiplied) = true || isNaN(amountToMultiplyFirst) = true || isNaN(amountToMultiplyLast) = true)
{
alert("YOU DID NOT ENTER ONLY NUMBERS. WAY TO GO DUMMY.");
var numberMultiplied = prompt("Please Enter The Number to Multiply");
var amountToMultiplyFirst = prompt("Start multiplying by which number?");
var amountToMultiplyLast = prompt("End multiplying by which number?");
}
for (counter = amountToMultiplyFirst; counter <= amountToMultiplyLast; counter++)
{
document.write(numberMultiplied + " * " + counter + " = " + numberMultiplied * counter + "<br />");
}
}
//Begin Program Below
multiplierz(prompt("Please Enter The Number to Multiply"),prompt("Start multiplying by which number?"),prompt("End multiplying by which number?"));
</script>
+1快訊的 – Brad 2011-04-18 04:07:02
什麼問題? – 2011-04-18 04:08:36
它不運行:P – bruchowski 2011-04-18 04:10:26