gpt4 book ai didi

javascript - JavaScript 因语法错误而遇到困难

转载 作者:行者123 更新时间:2023-11-28 15:03:48 27 4
gpt4 key购买 nike

我得到这个......未捕获的语法错误:参数列表后缺少)...当我尝试输入此代码时,我不知道如何修复它。

// flight_costs.js

function flightCosts() {

const cost_per_checked_bag = 50;
const typical_flight_speed = 575;
const hours_in_airport = 5;

var traveler_payrate_per_hour = Number(document.getElementById("traveler_payrate_per_hour").value);
console.log("traveler_payrate_per_hour" + traveler_payrate_per_hour);
var number_of_travelers = Number(document.getElementById("number_of_travelers").value);
console.log("number_of_travelers" + number_of_travelers);

//Flight Costs
var miles_flying = Number(document.getElementById("miles_flying").value);
console.log("miles_flying" + miles_flying);
var flight_cost = Number(document.getElementById("flight_cost").value)
console.log("flight_cost" + flight_cost);
var flight_transit_cost = Number(document.getElementById("flight_transit_cost").value);
console.log("flight_transit_cost" + flight_transit_cost);
var flight_discount = Number(document.getElementById("flight_discount").value);
console.log("flight_discount" + flight_discount);
var flight_amenities = Number(addCheckboxValues("flight_amenities") ||0;
console.log("flight_amenities" + flight_amenities);
var checked_bags_per_traveler = Number(document.getElementById("checked_bags_per_traveler").value);
console.log("checked_bags_per_traveler" + checked_bags_per_travelers);
var in_flight_amenities = Number(addCheckboxValues("in_flight_amenities") ||0;
console.log("in_flight_amenities" + in_flight_amenities);

var total_traveler_flight_cost = flight_cost * number_of_travelers;
console.log("total_traveler_flight_cost" + total_traveler_flight_cost);

var time_of_flight = miles_flying / typical_flight_speed;
console.log("time_of_flight" + time_of_flight);

var total_amenities = (flight_amenities + in_flight_amenities) * number_of_travelers;
console.log("total_amenities" + total_amenities);

var total_payrate_cost = (traveler_payrate_per_hour * (time_of_flight * 2) + hours_in_airport) ) * number_of_travelers;
console.log("total_payrate_cost" + total_payrate_cost);

var total_flight_checked_bags_cost = check_bags_per_traveler * cost_per_checked_bag * number_of_travelers;
console.log("total_flight_checked_bags_cost" + total_flight_checked_bags_cost);


var total_flight_cost = total_traveler_flight_cost + total_amenities +
total_flight_checked_bags_cost - flight_discount +
total_payrate_cost;
console.log("total_flight_cost" + total_flight_cost);


return total_flight_cost;
}

最佳答案

var Flight_amenities = Number(addCheckboxValues("flight_amenities") ||0;您在 ("flight_amenities") 之后缺少右括号。

编辑

此外,正如 fvu 所说,in_flight_amenities = Number(addCheckboxValues("in_flight_amenities")

关于javascript - JavaScript 因语法错误而遇到困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40051562/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com