Skip to content

Instantly share code, notes, and snippets.

@the-vampiire
Last active May 18, 2017 23:15
Show Gist options
  • Select an option

  • Save the-vampiire/0067be3761139bf143f33fb83d4ba24e to your computer and use it in GitHub Desktop.

Select an option

Save the-vampiire/0067be3761139bf143f33fb83d4ba24e to your computer and use it in GitHub Desktop.
Number Shortener
/**
* Created by Vampiire on 5/18/17.
*/
function shortenNum(num, decimals){
if(num.toString()[decimals+2] === "5"){
return Number(Number(num.toString().slice(0, decimals+2) + 6).toFixed(decimals));
}
return Number(num.toFixed(decimals));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment