-1
I’m starting at Node.js and have a little difficulty dealing with array/json, I’m in the learning process yet.
Assuming the following array of arrays:
Base array that should be filtered:
[
   {
      "id": 1,
      "nome":"Jonh Doe",
      "city":"NY",
      "status":"Single"
   },
   {
      "id": 2,
      "nome":"Mary",
      "city":"NY",
      "status":"Single"
   },
   {
      "id": 3,
      "nome":"Tom",
      "city":"CO",
      "status":"Married"
   },
   {
      "id": 4,
      "nome":"Mark",
      "city":"MI",
      "status":"Divorced"
   },
   {
      "id": 5,
      "nome":"Carl",
      "city":"NY",
      "status":"Single"
   },
]
You would need to save this same array in a variable but only where the key city is equal to NY. I researched about .map, .filter, .reduce, .indexOf but I could not reach a result. How could I achieve the following result:
Filtered array from NY only:
[
   {
      "id": 1,
      "nome":"Jonh Doe",
      "city":"NY",
      "status":"Single"
   },
   {
      "id": 2,
      "nome":"Mary",
      "city":"NY",
      "status":"Single"
   },
   {
      "id": 5,
      "nome":"Carl",
      "city":"NY",
      "status":"Single"
   },
]
Well explained Ricardo. The examples I saw were always
var array = [1, 2, 3, 4, 5]and filtering a specific number or something, I thought I would have different large ones to remove the entire array based on a key. I thought the.filterwould remove only that key and not the entire array. Thank you.– D. Watson