Skip to content

Instantly share code, notes, and snippets.

@tiendatleo
Last active June 30, 2022 07:22
Show Gist options
  • Save tiendatleo/5d49f39b38ce4cff5b911a9ecafdd36f to your computer and use it in GitHub Desktop.
Save tiendatleo/5d49f39b38ce4cff5b911a9ecafdd36f to your computer and use it in GitHub Desktop.
[JS] Convert number with such a number of decimals
function ParseFloat(str,val) {
str = str.toString();
str = str.slice(0, (str.indexOf(".")) + val + 1);
return Number(str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment