Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. function removeTrailingZeros(value) {
  2. value = value.toString();
  3.  
  4. if (value.indexOf('.') === -1) {
  5. return value;
  6. }
  7.  
  8. while((value.slice(-1) === '0' || value.slice(-1) === '.') && value.indexOf('.') !== -1) {
  9. value = value.substr(0, value.length - 1);
  10. }
  11. return value;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement