Tell us what’s happening:
Your code so far
function spinalCase(str) {
return str
.replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/\s+_*\s*|_+\s*_*/g, '-')
.toLowerCase()
}
console.log(spinalCase('This_ _ _ _ _ IsSpinalTap'));
//logs: this----is-spinal-tap.
//I know the code passes all the tests and that I can just
//continue adding \s* and _* but how can you make it work
//for any amount of spaces and underscores combined?
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Spinal Tap Case
Link to the challenge: