一切正常 - 除了这一个if-else-statement之外的所有内容:
else if ((day = 0 || day = 6) && (hour <= 19)) {
greeting = "We wish you a nice weekend and a nice " +
Weekdays[day] + ".";
}
Firefox的错误消息:&#39; ReferenceError:左侧无效的分配&#39;
..它应该很容易,但到现在为止我还没找到问题。
感谢您的帮助,祝您度过愉快的一天!
答案 0 :(得分:4)
使用==
进行比较(value
)和=
进行比较。
所以在你的情况下,它应该是:
...
else if ((day == 0 || day == 6) && (hour <= 19)) {
greeting = "We wish you a nice weekend and a nice " +
Weekdays[day] + ".";
}
...
如果您需要同时按type
和value
进行比较,则应使用===
简而言之:
var a = 10; // assigns value 10 to variable `a`
"1"==1 // true => Since == compares by value
"1"===1 // false => Since === compares by both type and value. In this case although value is 1, both are of different types (string and integer)