Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Decapitalize const

Instructions

Given a string representing constant name (upper case words separated by underscore eg FOO_BAR) implement a function which converts it into variable name (eg. fooBar):

  • convert first word to lowercase
  • convert next words to lowercase, but first character is still uppercase
  • remove all underscore characters

Challenge | Solution

Examples

decapitalizeConst("FOO") // foo

decapitalizeConst("FOO_BAR") // fooBar

decapitalizeConst("__FOO_BAR_BAZ") // fooBarBaz