Our function should return a new string, where all the occurrences of the word in the string that are present in the array are replaced by a whitespace.
Our function should use the String.prototype.replace() method to solve this problem.
The code for this will be −
The output in the console −
- Related Articles
- Python - Generate all possible permutations of words in a Sentence
- Print all words occurring in a sentence exactly K times
- Rearrange Words in a Sentence in C++
- Count words in a sentence in Python program
- Count palindrome words in a sentence in C++