javascript - if else-works,if else with ternary operator doesn't work -


i have simple if/else statement,and works normally,but doesn't work when replace if/else statement using ternary operator.

  if (upordown == -1 ) {     sec_in_view++   } else{     sec_in_view--   } 

that works,but how can make work using if/else statement ternary operator. tried this.

   (upordown == -1 ) ? sec_in_view++ : sec_in_view-- 

sorry acctually problem in previous line,which didn't had ";" on end,but line long , outside of view , tottaly forgot check that.

try assignment:

sec_in_view = (upordown == -1 ) ? sec_in_view+1 : sec_in_view-1; 

or

sec_in_view = (upordown == -1 ) ? sec_in_view++ : sec_in_view--; 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -