I am trying to Us the javascript splice method to add a "-" before every capital latter in my array but it is not working. I don't know what I am doing wrong. Here is my code below.
function spinalCase(str) {
let strArr = [];
for(let i = 0; i < str.length; i++){
strArr.push(str[i]);
}
for(let i = 0; i < strArr.length; i++){
if(strArr[i] !== strArr[i].toLowerCase()){
strArr.splice(strArr.indexOf(strArr[i]),0, "-");
}
}
console.log(strArr);
}
spinalCase('thisIsSpinalTap');