Skip to content

Instantly share code, notes, and snippets.

@jonasraoni
Created March 30, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonasraoni/368062ab9acfb04538e5279f0e41cc7b to your computer and use it in GitHub Desktop.
Save jonasraoni/368062ab9acfb04538e5279f0e41cc7b to your computer and use it in GitHub Desktop.
Given a list of numeric arguments, retrieves the longest amount of decimal places, useful to format :)
//+ Jonas Raoni Soares Silva
//@ http://raoni.org
export default (...values) => Math.max(...values.map(value =>
(value = (value + '').split(/[.,]/)).length > 1 && value.pop().length
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment