just confused with this solution am getting all passed except for one the question is
Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
and my code is
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
return str.split(/(?=[A-Z])/g).join("-").replace(/[" "_]/g,"").toLowerCase();
}
the error i get at freecode camp is when
str= "Teletubbies say Eh-oh";
output is =teletubbiessay-eh-oh
but frecodecamp say it must be ="teletubbies-say-eh-oh"
i used if the first letter is capttal letter thet where i split;
any ides
you don’t need to split only if the letter is upper case, what you need to do is change all spaces to dashes
“bLuE ElEpHaNT iS eATiNg BANanaS” should become “blue-elephant-is-eating-bananas”
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.