それで、私は割り当てを持っていて、今数時間それをやっていて、そのいくつかの部分で非常に行き詰まっています. したがって、私が立ち往生している部分は、プロンプトに入力された情報を検証するためにループを使用する必要があり、配列からの情報を使用して別の関数の変数と一致し、最終的にそのすべてを表示することです。
だから私はすべてをセットアップしましたが、誰かが私を正しい方向に向けるのを手伝ってくれたら、ここで何が間違っているのかわかりませんか? ああ、私は 2 番目の関数を配列に合わせようとしているので、ユーザーが数字 (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(
) );