convert snake_case to camelCase
2022年5月1日小于 1 分钟
convert snake_case to camelCase
Question
Do you prefer snake_case or camelCase ?
Anyway, please create a function to convert snake_case to camcelCase.
snakeToCamel('snake_case')
// 'snakeCase'
snakeToCamel('is_flag_on')
// 'isFlagOn'
snakeToCamel('is_IOS_or_Android')
// 'isIOSOrAndroid'
snakeToCamel('_first_underscore')
// '_firstUnderscore'
snakeToCamel('last_underscore_')
// 'lastUnderscore_'
snakeToCamel('_double__underscore_')
// '_double__underscore_'
contiguous underscore __
, leading underscore _a
, and trailing underscors a_
should be kept untouched.
Code
/**
* @param {string} str
* @return {string}
*/
function snakeToCamel(str) {
// your code here
}