title: matching values stored in variables or array with string javascript regex
body: <p>Im trying to find a patterns in the sentence for regex matching.. in the code below <code>result</code> contains a string and we are checking if the word <code>apple</code> is present in it.</p>
  
  <pre><code>    var patt = /apple/gi;
      var newResult = patt.test(result);
  </code></pre>
  
  <p>I found the above code from a used case.. But i was wondering if i have more than one values and i want to check it in the string result, lets say an array with values <code>var arr=["apple", "orange"]</code> <code>var patt=/arr[0]/gi</code>  will not work.. what could be the way in that scenario??</p>