The aim of the challenge is to create a hyphened word chaining. My question is how I could create an all-encompassing regex for the scenarios shown below:
I am able to do the first, third and fourth example.
function spinalCase(str) {
let result =str.toLowerCase().split(/\W/)
result.join('-')
return result;
}
spinalCase('This Is Spinal Tap');
spinalCase("Teletubbies say Eh-oh");
spinalCase("The_Andy_Griffith_Show");
spinalCase("thisIsSpinalTap")// My code does not work on these
spinalCase("AllThe-small Things")// My code does not work on these