Javascript - 左手边的任务

时间:2015-11-10 07:36:27

标签: javascript

我收到以下代码的左侧分配错误。我一遍又一遍地检查我的平等操作员,我找不到错误。

function priceCal() {
    //declares
    var hourRate = 0.01;
    var dayRate = 7;
    var fullDayHours = 6 * 60;

    var dateStart = $('#datepickerStart').datepicker('getDate');
    var hourStart = $('#timepickerStart').timepicker('getTime');
    var dateEnd = $('#datepickerEnd').datepicker('getDate');
    var hourEnd = $('#timepickerEnd').timepicker('getTime');

    var totalDays = (dateEnd - dateStart) / 24 / 60 / 60 / 1000; //we get total days
    var totalHours = (hourEnd - hourStart) / 60 / 1000;          //we get total minutes
    var startHours = (hourStart) / 60 / 1000;
    var endHours = (hourEnd) / 60 / 1000;

    var endRate = (hourEnd * hourRate);
    var startRate = (hourStart * hourRate);
    var daysRate = (totalDays * dayRate);

    // Both days are full
    if (totalDays > 0 && startHours >= 360 && endHours >= 360) {
        console.log("Rate is " + (totalDays * dayRate));
    }

    //Both days are not full
    if (totalDays > 0 && startHours < 360 && endHours < 360) {
        console.log("Rate is" + (totalDays * dayRate - 14) + (hourStart * hourRate) + (hourEnd * hourRate));
    }

    //Start day is full
    if (totalDays > 0 && startHours >= 360 && endHours < 360) {
        console.log("Rate is " = (totalDays * dayRate - 7) + (hourEnd * hourRate));
    }

    //End day is full
    if (totalDays > 0 && startHours < 360 && endHours >= 360) {
        console.log("Rate is " = (totalDays * dayRate - 7) + (hourStart * hourRate));
    }

提前谢谢

编辑:非常糟糕的问题,我对这个剧本编程非常鲁莽。

2 个答案:

答案 0 :(得分:2)

这是你的错误:

 console.log("Rate is " = (totalDays * dayRate - 7) + (hourEnd * hourRate));

应该是(如果你想要等号):

 console.log("Rate is = " + (totalDays * dayRate - 7) + (hourEnd * hourRate));

答案 1 :(得分:0)

console.log("Rate is " = (totalDays * dayRate - 7) + (hourStart * hourRate));

错过了Shift键的样子。