JSFiddle - React, Tailwind, and code Playground

by jasonwilczak

HTML

<div id="output"></div>

JavaScript

/*
This is the simplest version. Basically there's a 'full table scan' for each call to UserServiceFindUser. Each time, all
of the data elements are traversed and the results built from what matches the function parameter values.
*/

/*
Define the fields as well as how their value can be extracted from the record and what sort of comparisons should be
done to determine a match.
 */
const company = {
    value: function (pRecord) {
        return pRecord.company;
    },
    isMatch: function (pRecord, pValue) {
        return isExtractedStandardMatch(pRecord, "company", pValue)
    }
};

const job = {
    value: function (pRecord) {
        return pRecord.job;
    },
    isMatch: function (pRecord, pValue) {
        return isExtractedStandardMatch(pRecord, "job", pValue)
    }
};

const name = {
    value: function (pRecord) {
        if (!isEmpty(pRecord.name)) {
            let parts = pRecord.name.split(" ");
            if (parts.length > 0) {
                return parts[parts.length - 1];
            }
        }
        return null;
    },
    isMatch: function (pRecord, pValue) {

        if (!isExtractedStandardMatch(pRecord, "name", pValue)) {

            const lastNameValue = name.value(pRecord);

            return isStandardMatch(lastNameValue, pValue);

        } else {
            return true;
        }
    }
};


PrintOutResults("Hello World");

//TODO update the "UserServiceFindUser" function to return developers that work at the specified company only
var developersAtAwesomeSauceInc = UserServiceFindUser(null, "developer", "awesome sauce inc.");
PrintOutResults("Developers at Awesome Sauce Inc.", developersAtAwesomeSauceInc);

//TODO update the "UserServiceFindUser" function to return all people that work at the specified company
var peopleAtPandance = UserServiceFindUser(null, null, "pandance");
PrintOutResults("People at Pandance", peopleAtPandance);

//TODO update the "UserServiceFindUser" function to return all developers that work at the...