如何让它对“A' A'以外的输入作出相应的回应?和' a'?注意:没有.toUpperCase()或类似语句。它必须能够处理' A'并且' a'。最好保持开关声明
function Ticket() {
var ticketType = prompt('What type of ticket do you want');
var ticketQty = parseInt(prompt('How many tickets do you want'));
document.write('Ticket type is: ' + ticketType + '<br />');
document.write('Ticket quantity is: ' + ticketQty + '<br />');
ticketPrice = 0;
switch(ticketType) {
case 'A':
var ticketPrice = 100;
break;
case 'a':
var ticketPrice = 100;
break;
default:
ticketTypePrice();
}
function ticketTypePrice () {
if (ticketType == 'B') {
var ticketPrice = 75;
} else if (ticketType == 'C') {
var ticketPrice = 50;
} else {
document.write('Invalid Ticket Type' + '<br />');
}
}
if (ticketQty < 1 || ticketQty > 100) {
document.write('Invalid Quantity' + '<br />');
}
if (ticketPrice > 0 && ticketQty > 0 && ticketQty < 100) {
totalticketPrice = (ticketPrice * ticketQty);
document.write('Ticket Payment Required: ' + totalticketPrice);
}
}
Ticket();