意外标识每日奖励功能

时间:2015-01-21 14:59:01

标签: javascript html

在我的函数中出现意外的标识符错误。

的javascript

if (dailyRewardActive)                      //used to show how much time till it ends
{
    minutes = (((900000 - timer) / 60)/1000 - ((((900000 - timer)) % 60)/1000)
    seconds = ((900000 - timer) % 60000)   //getting it here

    document.getElementById("timer").innerHTML = minutes.toFixed(0)+":"+seconds.toFixed(0);
    timer = timer + 1000*timeBetweenTicks;
}

HTML

Time left on Daily Reward: <span id = "timer">0</span>

计时器是一个全局变量(我知道这是不好的做法,但此时此代码中很难改变)

1 个答案:

答案 0 :(得分:0)

上面一行中的括号不匹配(这并不奇怪,很难看!)。如果你将它们分开并匹配起来,你可以找到丢失的那个:

minutes = (
    (
        (900000 - timer) / 60
    ) /1000 - 
    (
        (
            ((900000 - timer)) % 60
        ) /1000
    )
//there's supposed to be another )
) //there we go