title: Check to see if array of strings contains a substring value in react
body: <p>I have an array of values and I'm looking to filter through the array to find usernames that contain the search query.</p>
  <p>The search query is taken as an input from the user.</p>
  <pre class="lang-js prettyprint-override"><code> useEffect(() =&gt; {
      let result;
      if (usernames != null) {
        result = usernames.filter((user) =&gt; user.username.includes(query));
      }
      console.log(result?.pop()?.username);
    }, [query]);
  </code></pre>
  <p>Any ideas what I am doing wrong?</p>
  <p><a href="https://i.stack.imgur.com/5Xder.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Xder.png" alt="enter image description here" /></a></p>