1

我正在尝试制作一个程序,用户可以在其中输入他们希望输入的 CD 数量,然后将输入的内容打印到屏幕上。

有没有办法从一个提示框中启用多个条目?

<script language="JavaScript">
var titleCD = [];
var costCD = [];
var subTotal = [];
var entries = parseInt(prompt("How many CDs do you wish to enter?",0)); 
while(entries>0) {
   titleCD = prompt("What is the title of your CD?");
   costCD = parseInt(prompt("What is the cost of that CD?", 0));
   entries--;
}
b = new String(titleCD + ": " + "£" + costCD + "<br>");
document.write(b.bold());
u = new String("The subtotal cost of all CDs is: £" + subTotal);
document.write(u.toUpperCase());
</script>
4

0 回答 0