JSFiddle - React, Tailwind, and code Playground

by kougiland

HTML

<form role="form">
    <input type="text" id="search" placeholder="Search...." />
</form>

JavaScript

if (!Array.prototype.every) {
    Array.prototype.every = function (fun /*, thisp*/ ) {
        var len = this.length >>> 0;
        if (typeof fun != "function") throw new TypeError();

        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in this && !fun.call(thisp, this[i], i, this)) return false;
        }

        return true;
    };
}

$('#search').keyup(function (e) {
    if (e.which !== 32) {
        var searchFieldValue = $('#search').val(),
            str = "The sky is awake so I am awake so we have to play",
            words = searchFieldValue.split(/\W+/),
            allPresent = words.every(function (a) {
            return str.search(new RegExp(a, 'img')) > -1;
        });
        console.log(allPresent);
        return allPresent;
    }
});