JavaScript Get list of key names based on values - Javascript excel list names based on criteria

I would like to get a list of key names based on a value I check.

This is what I have.

const data = {
  "DE": "ARUN",
  "HI": "ARUN",
  "PR": "ARUN",
  "TX": "ARUN",
  "MA": "ARUN",
  "MD": "CHARLES,BRANDON,DAVID,ARUN",
  "IA": "ARUN",
  "ME": "ARUN",
  "ID": "ARUN",
  "MI": "ARUN",
  "UT": "ARUN",
  "MN": "ARUN",
  "MO": "ARUN",
  "IL": "ARUN",
  "IN": "ARUN",
  "MS": "ARUN",
  "MT": "ARUN",
  "AK": "ARUN",
  "AL": "ARUN",
  "VA": "ARUN",
  "AR": "ARUN",
  "AS": "ARUN",
  "VI": "ARUN",
  "NC": "ARUN",
  "ND": "ARUN",
  "NE": "ARUN",
  "RI": "ARUN",
  "AZ": "ARUN",
  "NH": "ARUN",
  "NJ": "ARUN",
  "VT": "ARUN",
  "NM": "ARUN",
  "FL": "ARUN",
  "NV": "ARUN",
  "WA": "ARUN",
  "NY": "ARUN",
  "SC": "ARUN",
  "SD": "ARUN",
  "WI": "ARUN",
  "OH": "ARUN",
  "GA": "ARUN",
  "OK": "ARUN",
  "CA": "ARUN",
  "WV": "ARUN",
  "WY": "ARUN",
  "OR": "ARUN",
  "KS": "ARUN",
  "CM": "ARUN",
  "CO": "ARUN",
  "GU": "ARUN",
  "KY": "ARUN",
  "CT": "ARUN",
  "PA": "ARUN",
  "LA": "ARUN",
  "TN": "ARUN",
  "DC": "ARUN"
}

const name = 'BRANDON'

const newMappedData = Object.keys(data).map(key => {
  return {
    [key]: data[key].split(',')
  }
})

const filteredData = newMappedData.filter(item => Object.values(item).includes(name))


console.log(filteredData)
Answer:1

If you use includes you don't even need to split. Also you don't need to use map to create a new array:

const data = {
  "DE": "ARUN",
  "HI": "ARUN",
  "PR": "ARUN",
  "TX": "ARUN",
  "MA": "ARUN",
  "MD": "CHARLES,BRANDON,DAVID,ARUN",
  "IA": "ARUN",
  "ME": "ARUN",
  "ID": "ARUN",
  "MI": "ARUN",
  "UT": "ARUN",
  "MN": "ARUN",
  "MO": "ARUN",
  "IL": "ARUN",
  "IN": "ARUN",
  "MS": "ARUN",
  "MT": "ARUN",
  "AK": "ARUN",
  "AL": "ARUN",
  "VA": "ARUN",
  "AR": "ARUN",
  "AS": "ARUN",
  "VI": "ARUN",
  "NC": "ARUN",
  "ND": "ARUN",
  "NE": "ARUN",
  "RI": "ARUN",
  "AZ": "ARUN",
  "NH": "ARUN",
  "NJ": "ARUN",
  "VT": "ARUN",
  "NM": "ARUN",
  "FL": "ARUN",
  "NV": "ARUN",
  "WA": "ARUN",
  "NY": "ARUN",
  "SC": "ARUN",
  "SD": "ARUN",
  "WI": "ARUN",
  "OH": "ARUN",
  "GA": "ARUN",
  "OK": "ARUN",
  "CA": "ARUN",
  "WV": "ARUN",
  "WY": "ARUN",
  "OR": "ARUN",
  "KS": "ARUN",
  "CM": "ARUN",
  "CO": "ARUN",
  "GU": "ARUN",
  "KY": "ARUN",
  "CT": "ARUN",
  "PA": "ARUN",
  "LA": "ARUN",
  "TN": "ARUN",
  "DC": "ARUN"
}

const name = 'BRANDON'

const filteredData = Object.keys(data).filter(key => data[key].includes(name))

console.log(filteredData)
Answer:2

I have a requirement to display additional input tags based on user radio tag. I pasted the working code here. I wanted to display spouse first name and last name input tags. If not, will have to ...

I have a requirement to display additional input tags based on user radio tag. I pasted the working code here. I wanted to display spouse first name and last name input tags. If not, will have to ...

I would like to concat sub object array inside object in javascript. I have an object array inside an object: I would like to return the department sub array into one object array. var array = { ...

I would like to concat sub object array inside object in javascript. I have an object array inside an object: I would like to return the department sub array into one object array. var array = { ...

  1. concat object array javascript
  2. concat object array typescript
  3. concat object array
  4. concat object array c#
  5. concatenate object arrays javascript
  6. concatenate object arrays
  7. concat object into array javascript
  8. java concat object array
  9. js concat object array
  10. powershell concat object array
  11. javascript concat object array to string
  12. concat object to array react
  13. concat two object arrays javascript
  14. concat two object arrays java

Probably dead simple for someone out there, but I want to build a regex that will search across this string: foo[0][2] and return foo 0 2 in the array of matches So far I have come up with is \([...

Probably dead simple for someone out there, but I want to build a regex that will search across this string: foo[0][2] and return foo 0 2 in the array of matches So far I have come up with is \([...

  1. regex capture multiple lines
  2. regex capture multiple groups
  3. regex capture multiple matches
  4. regex capture multiple words
  5. regex capture multiple lines until
  6. regex capture multiple occurrences
  7. regex capture multiple times
  8. regex capture multiple values
  9. regex capture multiple
  10. regex capture multiple patterns
  11. regex capture multiple repeated groups
  12. regex capture multiple digits
  13. regex capture multiple groups python
  14. regex capture multi line
  15. regex multi capture group
  16. regex capture group multiple times
  17. javascript regex capture multiple groups
  18. perl regex capture multiple matches
  19. ruby regex capture multiple
  20. regex capture group multiple matches

I am studying the use of reduce in javascript, and I am trying to restructure an Array of Objects in a generic way - need to be dynamic. flowchart - i get totaly lost I started with this through. ...

I am studying the use of reduce in javascript, and I am trying to restructure an Array of Objects in a generic way - need to be dynamic. flowchart - i get totaly lost I started with this through. ...