简体   繁体   中英

convert variable of ternary operator to if-else statement

x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);  
alert(x);

hi guys, how can I convert this variable x to if-else statement returning the variable in true or false result?

thanks a lot

 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM