Be the first user to complete this post
|Add to List
A common case in many situations is to split user input on either a comma or a space.
The above code splits the string even if there are multiple spaces or commas consecutively.
filter function accepts a function as an argument and only adds elements to the result array if the function returns true.
In the case above, we pass the Boolean constructor as an argument. This returns false for all the empty strings that occur as a result of consecutive comma or spaces.Thats how you get an array of only the words you care about.
- window.onload vs document.onload
- css - circular profile pictures
- Two column layout in css
- Getting started with localStorage vs sessionStorage in html5
- pseudo elements vs pseudo classes
- Getting started with es6 iterators and iterables