将三元运算符的变量转换为 if-else 语句
convert variable of ternary operator to if-else statement
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
大家好,我如何将这个变量 x 转换为 if-else 语句,返回结果为 true 或 false 的变量?
非常感谢
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);
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
大家好,我如何将这个变量 x 转换为 if-else 语句,返回结果为 true 或 false 的变量?
非常感谢
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);