title: How to get all the matching values from an array in react native?
body: <p>How to get all the matching values from an array in react native?</p>
  <p>The array is <code>Sports = [ &quot;Football&quot;, &quot;Tennis&quot;, &quot;Volleyball&quot;, &quot;Squash&quot;, ]</code></p>
  <p>I tried getting all the matching values by using an if else statement below</p>
  <pre><code> useEffect(() =&gt; {
  
          if (((Sports[0] || Sports[1]) || (Sports[2] || Sports[3])) == &quot;Volleyball&quot;) { alert('Volleyball') }
  
          if (((Sports[0] || Sports[1]) || (Sports[2] || Sports[3])) == &quot;Football&quot;) { alert('Football') }
  
          if (((Sports[0] || Sports[1]) || (Sports[2] || Sports[3])) == &quot;Squash&quot;) { alert('Squash') }
  
      }, [Sports])
  </code></pre>
  <p>However the code would stops at the first value of the array which means it only runs the code block
  <code>if (((Sports[0] || Sports[1]) || (Sports[2] || Sports[3])) == &quot;Football&quot;) {alert('Football') }</code></p>
  <p>How can this be corrected or is there another way of getting all the matching values from the array?</p>