title: How to filter and match query from the URL against pre-defined keywords in an array
body: <p>I need to fetch &quot;q=how to book a bus ticket&quot;(this is the user search) from the URL and look for keywords to match against pre-defined keywords in an array. Also, we need to make sure the keyword is matched exactly against the keyword in the array then active a function. For e.g if the user searches for &quot;I need to buy a new bus&quot; then the function shouldn't be activated coz even tho it has the keyword &quot;bus&quot; in it but it didn't match the exact keyword &quot;bus ticket&quot; in the array.</p>
  <p>I have the code to fetch query param from the URL:</p>
  <pre><code>let params = (new URL(document.location)).searchParams;
  let searchedkeyword = params.get(&quot;q&quot;).toLowerCase();
  </code></pre>
  <p>Also, I have a list of keywords in an array:</p>
  <pre><code>var keyword = [new, book, old car, bus ticket]
  </code></pre>
  <p>I tried this one but didn't work:</p>
  <pre><code>let matchedkeyword = keyword.filter(str =&gt; str.match(searchedkeyword));
  </code></pre>
  <p>Let me know if this can be done in any other way using JS.</p>