0
當我運行程序時,我沒有得到任何輸出或錯誤。程序很簡單我必須在0-9之間生成7個7個隨機數,並將它們的值存儲在一個數組中,然後對於數組中的每個數字,我必須使用for循環來輸出每個值。沒有得到輸出或錯誤
var motto = [];
var randomNum = Math.floor(Math.random()*10);
for (i = 0; i < 7; i++) {
motto.pop(randomNum);
}
for (i = 0; i < motto.length; i++) {
document.write(motto[i] + "<br>");
}
您的意思是'motto.push',而不是'motto.pop'的問題? – Wondercricket
還把'var randomNum = Math.floor(Math.random()* 10);'在第一個'for'循環裏面有7個不同的數字 –
和**請不要使用document.write() - 這是從Javascript的嬰兒期起的一個醜陋的宿醉。 (嘗試console.log()或將內容注入DOM) – symcbean