JSFiddle - React, Tailwind, and code Playground

by Terry Mun

JavaScript

var query = "Define what is grape juice and how to drink it?",
    terms = ["define", "what is", "how to"],
    matchedTerms = [];

$.each(terms, function(i,v) {
    var match = query.indexOf(v);
    if(match > -1) matchedTerms.push(v);
});

console.log(matchedTerms);