Fix bug where `getPrecision` was undefined

- Reorder the Javascript code
- Ensure that we never call `getPrecision` on a string ("")