I don't get why my sol'n isn't passing the " Winter is coming"

what’s happening:
My solution seems to return the correct string exactly like the conditions say it should, but it’s saying I got it wrong.

code so far

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

// Only change code above this line
urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone");

Is telling me:

urlSlug(" Winter Is Coming") should return the string winter-is-coming .

But it does return exactly that. What gives?
Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

The issue is that split(" ") does not check for multiple spaces, this results in the output being “winter-is–coming”

I hope this helps you understand the problem. Happy coding!


Just after split(" ") try to filter only elements that are not empty.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.