dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.1 KiB
1.1 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69162d64f96574d9bb629eff | Challenge 114: Camel to Snake | 28 | challenge-114 |
--description--
Given a string in camel case, return the snake case version of the string using the following rules:
- The input string will contain only letters (
A-Zanda-z) and will always start with a lowercase letter. - Every uppercase letter in the camel case string starts a new word.
- Convert all letters to lowercase.
- Separate words with an underscore (
_).
--hints--
toSnake("helloWorld") should return "hello_world".
assert.equal(toSnake("helloWorld"), "hello_world");
toSnake("myVariableName") should return "my_variable_name".
assert.equal(toSnake("myVariableName"), "my_variable_name");
toSnake("freecodecampDailyChallenges") should return "freecodecamp_daily_challenges".
assert.equal(toSnake("freecodecampDailyChallenges"), "freecodecamp_daily_challenges");
--seed--
--seed-contents--
function toSnake(camel) {
return camel;
}
--solutions--
function toSnake(camel) {
return camel
.replace(/([A-Z])/g, "_$1")
.toLowerCase();
}