Correct faults

Your version didn't work. There was a declaration fault alongside with an identifier fault as Array.forEach does not return anything.
This commit is contained in:
David Wu
2017-12-24 14:44:26 +01:00
committed by GitHub
parent d4bec739be
commit 2f93862621

View File

@ -14,11 +14,9 @@ For more detailed explanation of this Regex [Visit this Site](https://regex101.c
```js ```js
const toKebabCase = str => { const toKebabCase = str => {
let regex = rx = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g; let regex = rx = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
let arr = str.match(regex); return str.match(regex).map(x =>{
arr = arr.forEach(x =>{ return x.toLowerCase();
return s.toLowerCase(); }).join('-');
});
return arr.join('-')
} }
// toKebabCase("camelCase") -> 'camel-case' // toKebabCase("camelCase") -> 'camel-case'
// toKebabCase("some text") -> 'some-text' // toKebabCase("some text") -> 'some-text'