title: How to match string values of two arrays using javascript
body: <p>I have two arrays</p>
  
  <pre><code>var arr1 = ['wq','qw','qq'];
  var arr2 = ['wq','wq','wq','qw','qw','qw','qw','qq','qq'];
  </code></pre>
  
  <p>Below what i did is matching <code>arr1</code> values with <code>arr2</code>. If the array contains same values i pushed the values into <code>newArr</code>.</p>
  
  <pre><code>var newArr = [];
  for (var i=0;i&lt;arr1.length;i++) {
      newArr[i] = [];
  }
  
  for (var i=0;i&lt;arr2.length;i++) {
      for (var j=0;j&lt;arr1.length;j++) {
          if (arr2[i].indexOf(arr1[j]) != -1)
              newArr[j].push(arr2[i]);
      }
  }
  console.log(newArr[1]); //newArr[0] = ['wq','wq','wq'];//In second output array newArr[1] = ['qw','qw','qw','qw'];
  </code></pre>
  
  <p>Is there any easy way to solve this without using two for loops. Better i need a solution in javascript</p>