dimanche 12 juillet 2020

Convert if/else into ternary [closed]

How would I convert this if/else statement into a ternary operator in a react component.

This works perfectly

     if(unit === 'Metric'){
         unit = 'Imperial';
     } else {
         unit = 'Metric';
     }

This doesn't

unit = 'Metric' ? 'Imperial' : 'Metric';

Aucun commentaire:

Enregistrer un commentaire