JSFiddle - React, Tailwind, and code Playground

by lid0

HTML

extract values from nested object and arrays. 
see result in console.log

JavaScript

var projects = [
   {
    "days" : [{
    "id": 1,
    "tags": [
        {
          "id": 1,
           "name": "foo"
         },
         {
          "id": 2,
           "name": "bar"
         },
      ]   
    }],
    "hours" : [{
      "id": 1,
      "tags": [{
        "id": 3,
        "name": "bar2"
        }]    
      }],
  },
     {
    "days" : [{
    "id": 1,
    "tags": [
        {
          "id": 1,
           "name": "p2-foo"
         },
         {
          "id": 2,
           "name": "p2-bar"
         },
      ]   
    }],
    "hours" : [{
      "id": 1,
      "tags": [{
        "id": 3,
        "name": "p2-bar2"
        }]    
      }],
  }
 
 
]
//extract tags to flat list
projects.flatMap((project)=>{
  return [ project.days .flatMap(day => day.tags.map(tag=>tag.name)) ,
           project.hours.flatMap(hour=>hour.tags.map(tag=>tag.name))
   ].flat()
})