所以我有一个任务,我现在已经做了几个小时,并且非常坚持其中的一些部分。因此,我坚持的部分是必须使用循环来验证放入提示中的信息,并使用数组中的信息与另一个函数中的变量相吻合,最后显示所有这些信息。
所以我已经设置好了所有东西,但是如果有人介意帮助我指出正确的方向,我不知道我到底出了什么问题?哦,我可能应该提到我试图让第二个函数与数组一起使用,因此当用户输入一个数字(1 到 4)时,它与数组中的价格匹配。
function numSeats() {
//var amountSeat=document.getElementById("price");
var amountSeat=prompt("Enter the amount of seats you would like");
amountSeat=parseInt(amountSeat);
for (i=7; i<amountSeat; i++){
if (amountSeat<1 || amountSeat>6) {
alert("Check the value of " + amountSeat);
location.reload(true);
}else{
alert("Thank You");}
}
return amountSeat;}
function seatingChoice() {
//var seatChoice=document.getElementById("table").innerHTML;
var seatChoice=prompt("Enter the seat location you want.");
seatChoice=parseInt(seatChoice);
for (i=7; i<seatChoice; i++){
if (seatChoice<1 || seatChoice>4) {
alert("Check what you entered for " + seatChoice);
location.reload(true);
}else{
alert("Thank You")}
}
return seatChoice;}
var price=new Array(60, 50, 40, 30);
var name=prompt("Please enter your name.");
if (name==null || name=="")
{
alert("You did not enter a name, try again");
location.reload(true);
}
else
{
alert("Thank You");
}
document.write(name + " ordered " + numSeats() + " for a total dollar amount of " + seatingChoice(
));