-
Hello, what is the correct way to get an array of all MASS units that mathjs supports? I want to show in a |
Beta Was this translation helpful? Give feedback.
Answered by
josdejong
Jun 28, 2023
Replies: 1 comment
-
You can loop through all units defined in Object.values(math.Unit.UNITS).filter(unit => unit.base.key === 'MASS') Note that each of the units can be prefixed too, like |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
luzfcb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can loop through all units defined in
math.Unit.UNITS
and filter those that have a base unit MASS, something like:Note that each of the units can be prefixed too, like
milligram
andkilogram
etc.