Finally completed this challenge
It took me almost 2 hours to understand what’s going on and finally complete the challenge
After dropping several ideas of asking for help, finally finished this on my own.
Here’s my solution for the challenge
function spinalCase(str) {
let pat = /(^[A-Z]?[a-z]+)[\s,$]?|([A-Z]?[a-z]+)[\s,$]?/g
let arr = str.match(pat)
arr = arr.map(str=>str.toLowerCase().trim())
return arr.join("-")
}
spinalCase('Teletubbies say Eh-oh');
Please, check the solution, and figure out any pitfalls, if any…