**Doesn’t Allow me to Pass even though it prints the results as asked in the exercise **
spinalCase("TheAndyGriffith_Show")
should return "the-andy-griffith-show"
It returns the exactly same in the log but someone says it doesn’t work
function spinalCase(str) {
//changes the first character of str to UpperCase
str = str.replace(str[0],str[0].toUpperCase());
//Regular Expression with 4 different Capture Groups
//Capture Group #1:(^[A-Z][a-z]+)
//Capture Group #2:([A-Z][a-z]+| [A-Z][a-z]+| [a-z]+)
//Capture Group #3:([A-Z][a-z]+| [A-Z][a-z]+|-[a-z]+)
//Capture Group #4:([A-Z][a-z]+| [A-Z][a-z]+|_[A-Z][a-z]+|-[a-z]+)')
const regex1 = new RegExp('(^[A-Z][a-z]+)([A-Z][a-z]+| [A-Z][a-z]+| [a-z]+)([A-Z][a-z]+| [A-Z][a-z]+|-[a-z]+)([A-Z][a-z]+| [A-Z][a-z]+|_[A-Z][a-z]+|-[a-z]+)');
//Creates an array of individual words based on grouping from Regex1
str = regex1.exec(str);
//Removes 'spaces','dashes', and 'underscores' from word in each index
str[2] = str[2].trim();
str[3] = str[3].trim().replace('-', '');
str[4] = str[4].trim().replace('-', '').replace('_', '');
//str = str[1]+str[2]+str[3]+str[4] with '-'
str = `${str[1]}-${str[2]}-${str[3]}-${str[4]}`
return str.toLowerCase()
}
console.log(spinalCase('This Is Spinal Tap'));
console.log(spinalCase("thisIsSpinalTap"))
console.log(spinalCase("TheAndyGriffith_Show"))
console.log(spinalCase("Teletubbies say Eh-oh"))
console.log(spinalCase("AllThe-small Things"))
Challenge: Spinal Tap Case
Link to the challenge: