也许删除一些逻辑运算符,制作“检查功能”?
还是将一些逻辑连接在一起?
// 功能
function getTicketPrice(childNumber,adultNumber){
if (childNumber > 2 && adultNumber > 2) {
return "-";
}
if (childNumber == 2 && adultNumber == 3) {
return "-";
}
if (childNumber == 3 && adultNumber == 2) {
return "-";
}
var sheet = SpreadsheetApp.openByUrl(url).getSheetByName("Ticket");
var row = getTicketPriceChild(childNumber, sheet);
var col = getTicketPriceAdult(adultNumber, sheet);
if (row >-1 && col === undefined) {
return "-";
}
if (row === undefined && col >-1) {
return "-";
}
var value = sheet.getRange(row, col).getValue();
if(value > 1){
return value;
} else {
return '-';
}
}
HUWWW
相关分类