Tell us what’s happening:
Your code so far
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
let caps = str.match(/^\w|[A-Z]/g);
let temp = str.split(/^\w|[A-Z]/g);
temp.splice(0,1);
console.log(temp);
for(let i=0; i<caps.length; i++){
temp[i] = caps[i].toLowerCase() + temp[i];
}
let output = [];
for(let i in temp){
let x = temp[i].match(/[a-z]/g);
output.push(x.join(''));
}
str = output.join('-');
return str;
}
console.log(spinalCase('AllThe-small Things'));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case
I fail this testcase. Can someone help me please ?