I am dealing with a range of status codes stored in an object retrieved from an API. The structure looks like this:
{
"location": [
"HOME_ADDRESS_INCOMPLETE",
"HOME_MISSING_ADDRESS"
],
"basics": [
"HOME_MISSING_TYPE"
],
...
}
Each key, such as location
, corresponds to a step in a setup wizard for the user based on the missing elements represented by constants like HOME_ADDRESS_INCOMPLETE
.
What would be the most efficient way to take this object and one constant, say MISSING_CURRENCY
, and determine the key associated with that constant's array?
This is my current attempt, but it only returns the array itself:
const activeStep = Object.values(HomeStatusCodes).filter(statusArray => {
return statusArray.includes(homeActivationResponse.code)
})