I have following string called name and I want to trim spaces between words in a sentence and to trim space after comma also.
I am able to trim extra spaces using trim() at the begining and end of the sentence.
[I am using javascript to implement my code]
name = ' Barack Hussein Obama II is an American politician who served as the 44th President of the United States from January 20, 2009, to January 20, 2017.
Expected Output:
name = ' Barack Hussein Obama II is an American politician who served as the 44th President of the United States from January 20, 2009, to January 20, 2017.