← Back to challenges

camelCase ⇄ snake_case

JavaScriptHardalgorithmsregexformattingstrings

Instructions

Create two functions toCamelCase() and toSnakeCase() that each take a single string and convert it into either camelCase or snake_case.

Examples

toCamelCase("hello_innokodakademija") ➞ "helloInnokodakademija"

toSnakeCase("helloInnokodakademija") ➞ "hello_innokodakademija"

toCamelCase("is_modal_open") ➞ "isModalOpen"

toSnakeCase("getColor") ➞ "get_color"

Notes

Test input will always be appropriately formatted as either camelCase or snake_case, depending on the function being called.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.