TypeError:str.spilt() is not function

Whenever i want to convert string in to array editor displays this message: TypeError:str.spilt() is not function
My program:

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
var arr =str.spilt('');
}

spinalCase('This Is Spinal Tap');

You have a typo…

spilt (as in you spilt/spilled your drink)
instead of
split (break it down)

also, the function needs a return statement.

1 Like
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
var arr =str.spilt('');
  for(var i=1;i<arr.length;i++){
    if(str[i]==str[i].toUpperCase()){
      arr.splice(i,0,"-");
    }
    else if(str[i]=='_'){
      arr.splice(i,1,"-");
    }
    else if(str[i]==' '){
      arr.splice(i,1,"-");
    }
     
  }
  str1 = arr.join('');
  str1 = str1.toLowerCase();
  return str1;
}

spinalCase('This Is Spinal Tap');
```

I’m just gonna repeat what I said earlier…

Sorry,I didn,t get you.Please tell me in code.I am not a native english speaker.

'spilt' === 'split'
>> false
2 Likes

Always check for typos is good coding rule of thumb. Code editor in FCC colors functions (red, I think) so if you type stuff wrong it will likely be the wrong color.

you spelled split wrong