开发者

Javascript dual If statements

With the fo开发者_运维技巧llowing code I am trying to set both the test title and object. The code works if I use one line but not both.

if (today <= test0) var testTitle = testTitle0
if (today <= test0) var testObject = testObject0

Outcome:

if (today <= test0) var testTitle = testTitle0 & var testObject = testObject0


You are missing curly braces and semicolons:

if (today <= test0) {
    var testTitle = testTitle0,
        testObject = testObject0;
}


if (today <= test0) 
{
    var testTitle = testTitle0;
    var testObject = testObject0;
}

Learn to use braces around if statements and semicolons at the end of your lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜