* fix: consolidate/remove comments * fix: remove => from comment * fix: reverted changes to add same changes to another PR * fix: removed 'the' from sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: removed 'the' from the sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
1.7 KiB
1.7 KiB
id, title, isRequired, challengeType, forumTopicId
id | title | isRequired | challengeType | forumTopicId |
---|---|---|---|---|
a103376db3ba46b2d50db289 | Spinal Tap Case | true | 5 | 16078 |
Description
Instructions
Tests
tests:
- text: <code>spinalCase("This Is Spinal Tap")</code> should return <code>"this-is-spinal-tap"</code>.
testString: assert.deepEqual(spinalCase("This Is Spinal Tap"), "this-is-spinal-tap");
- text: <code>spinalCase("thisIsSpinal<wbr>Tap")</code> should return <code>"this-is-spinal-tap"</code>.
testString: assert.strictEqual(spinalCase('thisIsSpinalTap'), "this-is-spinal-tap");
- text: <code>spinalCase("The_Andy_<wbr>Griffith_Show")</code> should return <code>"the-andy-griffith-show"</code>.
testString: assert.strictEqual(spinalCase("The_Andy_Griffith_Show"), "the-andy-griffith-show");
- text: <code>spinalCase("Teletubbies say Eh-oh")</code> should return <code>"teletubbies-say-eh-oh"</code>.
testString: assert.strictEqual(spinalCase("Teletubbies say Eh-oh"), "teletubbies-say-eh-oh");
- text: <code>spinalCase("AllThe-small Things")</code> should return <code>"all-the-small-things"</code>.
testString: assert.strictEqual(spinalCase("AllThe-small Things"), "all-the-small-things");
Challenge Seed
function spinalCase(str) {
return str;
}
spinalCase('This Is Spinal Tap');
Solution
function spinalCase(str) {
str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');
return str.toLowerCase().replace(/\ |\_/g, '-');
}