URL Slugs -- Need Help With Removing All Whitespace

I can’t figure out how to remove all whitespace from a string. I tried Googling, but I only get stuff showing how to do it using replace (the challenge says my should not use replace).

Any help is appreciated.

My code so far

// The global variable
var globalTitle = "Winter Is Coming";

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

// Only change code above this line

Your browser information:

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

Challenge: Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

Never mind, I managed to get it. I put

.filter(str => {
  return str.trim();

in there before .join() and it worked.

you can also put a regex inside here, so that you can do it on any number of spaces

no, this doesn’t do what you want: filter will keep the elmenets in the array for which it returns a truthy value and and not keep for those of which it returns a falsy value. I don’t think trim is doing what you want there

My code passed all of the tests. I may have to try my own tests then.

it accidentally works, but not because it does what you want