// Problem: Create a UI that will display a list of fields // that will have nesting based on dot notation... // Example fields const exampleFields = [ 'name', 'description', 'entity.hostname', 'entity.url', 'entity.ipaddress.name', 'signal.url' ]; // Return results => [ { name: 'foo', children: [...] } ] // const results = []; // Given a field name, recurse to find parent const recurse = (prop, parent) => { const split = prop.split('.'); /* if (split.length === 1) { results.push(prop); } else { const [first, ...rest] = split; const has = } */ }; const results = exampleFields.reduce((acc, prop) => { const [first, ...rest] = prop.split('.'); console.log(rest) return acc; }, [])