I have a object:
child_el = {
          height: sub_height,
          top: sizes.top,
          color: if sizes.top == 1 ? 0 : 1,
          };
How I can correctly put condition in property color?
I have a object:
child_el = {
          height: sub_height,
          top: sizes.top,
          color: if sizes.top == 1 ? 0 : 1,
          };
How I can correctly put condition in property color?
 
    
    You just need to remove the if from color property.
Check the below code :
child_el = {
   height: sub_height,
   top: sizes.top,
   color: sizes.top === 1 ? 0 : 1
};
Reference : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
 
    
    child_el = {
   height: sub_height,
   top: sizes.top,
   color: sizes.top === 1 ? 0 : 1,
};
