我是js的新手,但非常熱衷於學習。我想讓2「for」循環。 1.將6次表格的值存儲到一個數組(timesTable)中,最大爲12x6。 2.將這些存儲值輸出到控制檯(例如0 x 6 = 0,1 x 6 = 0,)。非常感謝。For循環和數組的簡單時間表?
<script>
var timesTable = new Array();
var multiplier = 6;
timesTable[0] = 0 * multiplier;
timesTable[1] = 1 * multiplier;
timesTable[2] = 2 * multiplier;
timesTable[3] = 3 * multiplier;
timesTable[4] = 4 * multiplier;
timesTable[5] = 5 * multiplier;
console.log("0 x " + multiplier + " = " + timesTable[0]);
console.log("1 x " + multiplier + " = " + timesTable[1]);
console.log("2 x " + multiplier + " = " + timesTable[2]);
console.log("3 x " + multiplier + " = " + timesTable[3]);
console.log("4 x " + multiplier + " = " + timesTable[4]);
console.log("5 x " + multiplier + " = " + timesTable[5]);
</script>
好吧,這聽起來像你確切地知道你需要做什麼。什麼讓你保持? – Tomalak
[前進](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for)! – Bergi