* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.3 KiB
1.3 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
a103376db3ba46b2d50db289 | Spinal Tap Case | 5 | 16078 | spinal-tap-case |
--description--
Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
--hints--
spinalCase("This Is Spinal Tap")
should return "this-is-spinal-tap"
.
assert.deepEqual(spinalCase('This Is Spinal Tap'), 'this-is-spinal-tap');
spinalCase("thisIsSpinalTap")
should return "this-is-spinal-tap"
.
assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap');
spinalCase("The_Andy_Griffith_Show")
should return "the-andy-griffith-show"
.
assert.strictEqual(
spinalCase('The_Andy_Griffith_Show'),
'the-andy-griffith-show'
);
spinalCase("Teletubbies say Eh-oh")
should return "teletubbies-say-eh-oh"
.
assert.strictEqual(
spinalCase('Teletubbies say Eh-oh'),
'teletubbies-say-eh-oh'
);
spinalCase("AllThe-small Things")
should return "all-the-small-things"
.
assert.strictEqual(spinalCase('AllThe-small Things'), 'all-the-small-things');
--seed--
--seed-contents--
function spinalCase(str) {
return str;
}
spinalCase('This Is Spinal Tap');
--solutions--
function spinalCase(str) {
str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');
return str.toLowerCase().replace(/\ |\_/g, '-');
}