Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

Hello everyone, i have some question, i was doing a challenge (you’ll find the link below) and i searched for a solution, of course i’ve founded FCC solutions , it worked and all yet i have a problem with it. It’s doesn’t make sense to type :

trim().split(/+s/);

trim() function removes all the white spaces, which means that the code later won’t match any white space. Which means that split(/+s/) won’t work, because there would be no white spaces anymore, it were removed using trim() function.

The solution worked, yet i am open for an explanation for this.

And thank you

Challenge Information:

Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

1 Like

trim removes spaces from the start and ending of the string, it keeps the spaces that are inside string (ie. between some letters).

1 Like