Applying Functional Programming to Convert Strings to URL Slugs

why is my code not passing???
Tell us what’s happening:
Describe your issue in detail here.

   **Your code so far**

// Only change code below this line
function urlSlug(title) {
return title.toLowerCase().split(/\s+/).join("-")

}
// Only change code above this line
console.log(urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone"));
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

Because this test case

" Winter Is  Coming"

has a leading space and two spaces between Is and Coming and they all are replaced by -.
One option would be to filter out empty values after splitting.

thanks i passed the test