2018-10-10 18:03:03 -04:00
---
id: a103376db3ba46b2d50db289
title: Spinal Tap Case
isRequired: true
challengeType: 5
2019-08-28 16:26:13 +03:00
forumTopicId: 16078
2018-10-10 18:03:03 -04:00
localeTitle: Чехол для спинного диска
---
## Description
2019-08-28 16:26:13 +03:00
< section id = 'description' >
2019-11-19 19:54:48 -05:00
Преобразуйте строку в спинальный регистр. Спинальный чехол - все-строчные слова, соединенные тире. Н е забудьте использовать < a href = "https://www.freecodecamp.org/forum/t/how-to-get-help-when-you-are-stuck-coding/19514" target = "_blank" > Read-Search-Ask,< / a > если вы застряли. Попробуйте подключить программу. Напишите свой собственный код.
2019-08-28 16:26:13 +03:00
< / section >
2018-10-10 18:03:03 -04:00
## Instructions
2019-08-28 16:26:13 +03:00
< section id = 'instructions' >
2018-10-10 18:03:03 -04:00
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2019-08-28 16:26:13 +03:00
- 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");
2018-10-10 18:03:03 -04:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
return str;
}
spinalCase('This Is Spinal Tap');
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2019-08-28 16:26:13 +03:00
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.replace(/([a-z ](?=[A-Z] ))/g, '$1 ');
return str.toLowerCase().replace(/\ |\_/g, '-');
}
2018-10-10 18:03:03 -04:00
```
2019-08-28 16:26:13 +03:00
2018-10-10 18:03:03 -04:00
< / section >