TypeError:str.spilt() is not function

TypeError:str.spilt() is not function
0

#1

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');

#2

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.


#3
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');
```

#4

I’m just gonna repeat what I said earlier…


#5

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


#6

I’ve edited your posts for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard.


#7
'spilt' === 'split'
>> false

#8

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.


#9

you spelled split wrong