Apply-functional-programming-to-convert-strings-to-url-slugs

Apply-functional-programming-to-convert-strings-to-url-slugs
0

I found the mistake, I should have added + on W so it is W+ which means find one or more spaces, and changed trim to be the first method

I used match for any non white space repeating characters.
However, I am curious which is more efficient between using Filter, Map, Trim, or etc.

return title.toLowerCase().match(/\S+/g).join('-');


return title.toLowerCase().trim().split(/\W+/).join("-");

It works for me!