1
所以我有這個,我需要它以相反的順序出現。我試過.reverse();但仍然無法實現其工作。有人可以幫忙嗎?使用提示時反向陣列
<button onclick="result()">Click here</button>
<script>
function result()
{
var i = 0;
var outMessage = "";
var studNames = new Array(5);
var studMarks = new Array(5);
for (i = 0; i < 5; i++)
{
studNames[i] = prompt('Enter next name - ' , "");
studMarks[i] = prompt('Enter next mark - ' , 0);
}
for (i = 0; i < 5; i++)
{
outMessage = outMessage + studNames[i] + studMarks[i] + "\n";
}
alert (outMessage);
}
</script>
請準確告訴需要幫助?你是否想要以相反順序將名稱和標記添加到outMessage中? – ShwethaU