正如你看到我的代碼,我在 2-3 次后在 while 循環(huán)中輸入一個(gè)數(shù)字,但它沒(méi)有返回任何值或表格。我應(yīng)該顯示輸入的數(shù)字表。當(dāng)我第一次嘗試輸入數(shù)字時(shí),它會(huì)返回表格,但在第 3-4 次嘗試中,它只接受該值,但不返回任何表格。<script type="text/javascript"> var num = prompt('Enter a number for which you want to display the table'); if(num.length === 0){ while(num.length === 0){ var num = prompt('Enter a number for which you want to display the table'); } }else{ num2 = Number(num); for(var i = 1; i <= 10; i++){ document.write(num2 * i + '<br>'); } }</script>
使用while循環(huán)后顯示表格出錯(cuò)
慕運(yùn)維8079593
2023-08-18 16:39:38