Created
February 19, 2016 11:09
-
-
Save oropesa/9a9274ad7b65bd157ce6 to your computer and use it in GitHub Desktop.
Cast Number to String. The last digit is separated by a stripe
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
| var num2camelString = function( numero ) { | |
| var string = numero + ""; // 4 23 132 30 | |
| if( string.length === 1 ) { // t f f f | |
| string = "0" + string; // 04 23 132 30 | |
| } | |
| string = string.substring( 0, string.length - 1 ) // 0 2 13 3 | |
| + "-" // - - - - | |
| + string.substr( string.length - 1, 1 ); // 4 3 2 0 | |
| if( string.lastIndexOf( "0" ) === string.length -1 ) { | |
| string = string.substring( 0, string.length -2 ); // 0-4 2-3 13-2 3 | |
| } | |
| return string | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment