Skip to content

Crosswalk Transformer From Database #6330

Answered by pacmano1
EthanKC asked this question in Q&A
Discussion options

You must be logged in to vote

it is likely much better to load that table to a $g object as an object and just do the lookup directly.

var lookupTable = [
    { zip: "10001", city: "New York" },
    { zip: "90001", city: "Los Angeles" },
    { zip: "60601", city: "Chicago" },
    { zip: "77001", city: "Houston" },
    { zip: "85001", city: "Phoenix" },
    { zip: "19101", city: "Philadelphia" },
    { zip: "75201", city: "Dallas" },
    { zip: "94101", city: "San Francisco" },
    { zip: "33101", city: "Miami" },
    { zip: "30301", city: "Atlanta" }
];

var findCityByZip = (zipCode) => {
    const entry = lookupTable.find(entry => entry.zip === zipCode);
    return entry ? entry.city : null;
};

var result = findCity…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@EthanKC
Comment options

@pacmano1
Comment options

Answer selected by EthanKC
@EthanKC
Comment options

@pacmano1
Comment options

@EthanKC
Comment options

@pacmano1
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants