How to get the unit in it's abbreviated form (a.k.a get m from unit.toJSON().unit instead of meters?
              
              #3236
            
            
              
                Unanswered
              
          
                  
                    
                      rafaellehmkuhl
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment
-
| 
         
 There is no built-in solution to ensure outputting abbreviations only. Maybe you can create list with the unit names and their abbreviations, and write a RegExp to replace them in the output (mind any prefixes like   | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I have a situation where I want to allow the user to choose the unit in which a variable can be displayed. The
Unitmodule ofmathjsis perfect for that.Currently I can access
unit(x, 'm').toJSON().unitand receivemeters.Is there a way I can have this unit name in it's abbreviated form (
m)?Beta Was this translation helpful? Give feedback.
All reactions