【发布时间】:2017-05-30 11:01:06
【问题描述】:
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
大家好,我怎样才能将此变量 x 转换为 if-else 语句,以 true 或 false 结果返回变量?
非常感谢
【问题讨论】:
标签: javascript if-statement operator-keyword ternary
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
大家好,我怎样才能将此变量 x 转换为 if-else 语句,以 true 或 false 结果返回变量?
非常感谢
【问题讨论】:
标签: javascript if-statement operator-keyword ternary
year = 2010;
if(year % 100 === 0)
x = (year % 400 === 0);
else
x = (year % 4 === 0);
alert(x);
if(year % 100 === 0)
x = (year % 400 === 0);
else
x = (year % 4 === 0);
alert(x);
【讨论】: