Skip to content

Instantly share code, notes, and snippets.

@williammustaffa
Last active July 17, 2018 19:00
Show Gist options
  • Select an option

  • Save williammustaffa/c295f9ba19262ac22fc047069effe658 to your computer and use it in GitHub Desktop.

Select an option

Save williammustaffa/c295f9ba19262ac22fc047069effe658 to your computer and use it in GitHub Desktop.
custom toFixed to prevent rounding values
Number.prototype.customToFixed = function (digits) {
return parseFloat(String(this).replace(new RegExp(`(\\d+\\.\\d{${digits}}).*`), '$1'));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment