Replace words in a string
<p>I have an array as follows:</p>

<pre><code>var arr = ["apple", "banana", "carrot"];
</code></pre>

<p>I want to replace all sentences which have the words similar to the array</p>

<pre><code>function replaceString(fruits){
return fruits.replace(arr, "---");
}
</code></pre>

<p>So if I pass a string - "An apple a day keeps", it should return "An --- a day keeps"  </p>

<p>How can I do it?</p>
