Skip to content

Instantly share code, notes, and snippets.

@oropesa
Created February 19, 2016 11:09
Show Gist options
  • Save oropesa/9a9274ad7b65bd157ce6 to your computer and use it in GitHub Desktop.
Save oropesa/9a9274ad7b65bd157ce6 to your computer and use it in GitHub Desktop.
Cast Number to String. The last digit is separated by a stripe
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