Difficulty Rating: 2.5/5
All problems have different strategies and solutions. For the current problem, you can use an Array or a String to convert the string into camelCase. Choose the method you feel most comfortable with and come to your own solution.
The string approach will take a few concepts you are familiar with such as String Iteration, possibly nested if statements, and more.
Here are a few tips to keep in mind:
Arrays have many methods that make manipulating strings convenient. Here are a few of them:
With the Array approach, the first step is to create an array out of the initial string. Use the Array.prototype.split method, what arguments does it take? Can you split on the underscore?
Now that you have an array of words split on underscores, most of your work is done! Loop over each word in the array (except the first word), make the first character in the word uppercase, and the rest of the characters lowercase. Keep in mind the first word should be all lowercase.