Hi I’m not sure how to remove the extra space in the beginning of the strings. I noticed in the solution “hint” they used .filter(obj => { return obj !== ""; }) but I’m not understanding how and how to solve with my approach. Thanks
**Your code so far**
// Only change code below this line
function urlSlug(str) {
return str
.toLowerCase()
.split(" ")
.join("-");
}
console.log(urlSlug(" Winter Is Coming"));
// Only change code above this line
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36.
Challenge: Apply Functional Programming to Convert Strings to URL Slugs
Thank you @sitek94@JeremyLT but for some reason it’s not passing one test, even though it is returning the right string “winter-is-coming”
// Only change code below this line
function urlSlug(str) {
return str
.trim()
.toLowerCase()
.split(" ")
.join("-");
}
console.log(urlSlug(" Winter Is Coming"));
// Only change code above this line