Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
(+) operator doing that job
eg:"WUBWUBWUBWUB".replace(/(WUB)/g) is equal to " " so in this case we get four empty spaces. because it replace every WUB into empty string tha't why we are using + symbol it means it check minimum one 'WUB' matches.
eg1:"WUB".replace(/(WUB)+/g) is equal to " ",
eg2:"WUBWUB".replace(/(WUB)+/g) is equal to " ",
eg3:"WUBWUBWUBWUB".replace(/(WUB)+/g) is equal to " ".in this case there are fout 'WUB' substrings are here so it replace that string into one empty string
How does this code remove the multiple spaces? I can only understand how it replaces the WUBs with a space each time, not how it accounts for the potential multiple spaces