Created
July 1, 2015 18:11
-
-
Save aradnom/4ea9343148d2c4f476a0 to your computer and use it in GitHub Desktop.
Dashes to camelCase
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
/** | |
* Given a string-like-this, return a stringLikeThis. | |
* | |
* @param {String} str String to transform | |
* | |
* @return {String} Returns camelCased string | |
*/ | |
function dashesToCamelCase ( str ) { | |
return str | |
.split( '-' ) | |
.map( function ( chunk, index ) { | |
return index > 0 | |
? chunk.substr( 0, 1 ).toUpperCase() + chunk.substr( 1, chunk.length ) | |
: chunk; } ) | |
.join( '' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment