I need to split a keyword string and turn it into a comma delimited string. However, I need to get rid of extra spaces and any commas that the user has already input.
let query = "split me by space and remove trailing spaces and store in an array "; let words = query.trim().split(" "); console.log(words)
Output : [ 'split', 'me', 'by', 'space','and','remove', 'trailing', 'spaces', 'and', 'store', 'in', 'an', 'array' ]