Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log(str.match(/[A-Z][a-z]+/g));
- function spinalCase(str) {
- arr = [" ", "-", "_"];
- for (i = 0; i < str.length; i++) {
- if (i !== 0 && str[i] === str[i].toUpperCase() && arr.indexOf(str[i - 1]) === - 1 && arr.indexOf(str[i]) === - 1) {
- console.log(str[i], str[i - 1], str);
- }
- }
- str = str.replace(/ /g, "-");
- str = str.replace(/_/g, "-");
- return str;
- }
- spinalCase('thisIsSpinalTap');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement