0
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
嗨,大家好,我怎麼可以把這個變量x if-else語句在真或假的結果返回的變量?轉換三元運算符的變量if-else語句
非常感謝
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
alert(x);
嗨,大家好,我怎麼可以把這個變量x if-else語句在真或假的結果返回的變量?轉換三元運算符的變量if-else語句
非常感謝
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);
@AhQuan檢查片段 –
感謝隊友!但如果我這樣鍵入(使用{}),那麼如果(year%100 === 0)x =(year%400 === 0); } else { x =(year%4 === 0); alert(x); } –
有什麼想法爲什麼?對不起,我無法將代碼粘貼到評論部分 –