SyntaxFix
Write A Post
Hire A Developer
Questions
Pure regex answer
n.replace(/(\.[0-9]*[1-9])0+$|\.0*$/,'$1');
I wonder why no one gave one!