JSFiddle - React, Tailwind, and code Playground

by Rodwyn Moreno

JavaScript

const sites = [
	{
   "SiteId": "S10003366085",
    "Name": "BARRY ZAMER",
    "Address": "284 LOCUST ST # 1",
    "City": "FLORENCE",
    "State": "MA",
    "Zip": "01062-2036",
    "CreatedDt": "2007-04-11",
    "CreatedBy": "matthewmartin",
    "Activity": [],
    "Appointments": [],
    "Measures": [],
    "Documents": [],
  },
  {
   "SiteId": "S10003366086",
    "Name": "BARRY ZAMER",
    "Address": "284 LOCUST ST # 2",
    "City": "FLORENCE",
    "State": "MA",
    "Zip": "01062-2036",
    "CreatedDt": "2007-04-11",
    "RevisedBy": "CSG_OWNE",
    "Activity": [],
    "Appointments": [],
    "Measures": [],
    "Documents": [],
  },
  {
   "SiteId": "S10003366087",
    "Name": "BARRY ZAMER",
    "Address": "284 LOCUST ST # 3",
    "City": "FLORENCE",
    "State": "MA",
    "Zip": "01062-2036",
    "Activity": [],
    "Appointments": [],
    "Measures": [],
    "Documents": [],
  },
];


const xxx = sites.map(site => {
  return Object.keys(site).filter(key => (typeof site[key]) !== 'object');
}).reduce((a, b) => [...a, ...b], []).reduce((unique, item) => {
	console.log(typeof unique, typeof item);
	return unique.includes(item) ? unique : [...unique, item];
}, []);

/* array.reduce((unique, item) => {
  return unique.includes(item) ? unique : [...unique, item];
}, []); // 👈 The initial value of our Accumulator is an empty array */

console.log(xxx);