Created
July 11, 2022 12:37
-
-
Save itzarty/96e7439a63ac3800335ecb72a63d255c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.placeFormat = function( places, limited ) { | |
if( !places || places < 2 ) places = 2; | |
if( !limited ) limited = true; | |
var number = this.toString( ); | |
if( number.length > places && limited == true ) return number.slice( 0, places - number.length ); | |
if( number.length < places ) { | |
while( number.length != places ) { | |
number = "0" + number; | |
} | |
return number; | |
} | |
if( number.length == places ) return number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment