JSFiddle - React, Tailwind, and code Playground

JavaScript

$(document).ready(function () {
    var words = ['john','dress'];
    $('#input').on('keyup',function () {
        var value = $(this).val();
        var matches = [];
        words.forEach(function (item) {
            if (item.indexOf(value) > -1 ) {
                matches.push(item);
            } else if (item.indexOf("")){
                matches = [];
            }
        });
        var match = "";
        matches.forEach(function (item) {
           match += item + "<br>";
        });
        $('p').html(match);
    });
});