hi there wondering if i can do this better soi dont have to have the
if(arr[0]===’ '){
arr.shift();
}
the challange :https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case
here is the code
function spinalCase(str) {
let str1= str.replace(/[A-Z]/g, function(v) {return ' '+ v.toLowerCase();
});
let arr=str1.split(/[\s,._]+/);
console.log(arr);
console.log(arr[0]);
if(arr[0]===''){
arr.shift();
}
let str2=arr.join('-')
console.log(str2)
return str2;
}
spinalCase("The_Andy_Griffith_Show");