Help needed in understanding strange behaviour

I am trying to understand the peculiarity of this challenge.
The code challenge can only be passed by using .split(/\s+/) instead of .split(' ').

The code test below shows that there are no empty strings in the array which may be causing the issue. Am I correct in saying that there may be zero-width spaces contained in title?

function urlSlug(title) {
console.log(title
  .toLowerCase()
  .trim()
  .split(' ')); //logs [ 'winter', 'is', 'coming']

return title
  .toLowerCase()
  .trim()
  .split(' ')
  .join('-');
}

urlSlug(" Winter Is  Coming");
//returns 'winter-is-coming' does not pass test

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

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

Are you sure that this is true?

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