I’m so close to passing this challenge but I’m getting an extra hyphen? I’m getting this
-winter-is-coming
Here’s my code
// Only change code below this line
function urlSlug(title) {
return title.split(" ").join("-",).toLowerCase();
}
// Only change code above this line
console.log(urlSlug(" Winter Is Coming"));
I suppose you could do that but the key here is that you want to get rid of any unnecessary white space at the beginning and end of the string. There is actually a JS string method for doing this exact thing.
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 it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
We don’t encourage users to give out full solutions when assisting others on the forum.
It is best to help them through hints so they can solve it themselves.
But also, the directions say not to use the replace method so your code would not pass the FCC tests.