Create a Flat version of a nested Object | Breadcrumbs Computation | JavaScript Interview Question
@Yomesh Gupta

Do you see value in our efforts?

Devtools Tech is a free platform for Frontend Engineers. It takes a lot of time, effort, and finanical resources to keep the platform running. If you see any value in our work and would like to support us then you can do using the following options.


In many websites like E-commerce, Dashboards, etc there are breadcrumbs that users use to navigate between pages. This question is around that only. Suppose, you are given a nested object from the backend and you need to create a flat version of the object that can be used for breadcrumbs.

const data = {
  name: 'Devtools Tech',
  channel: {
    youtube: {
      link: '',
      name: 'Devtools Tech',
      subscribe: "true"
    platform: {
      link: '',
      resources: {
        pages: ['/questions', '/resources']

const output = transform(data, 'data');

    data_name: 'Devtools Tech',
    data_channel_youtube_link: '',
    data_channel_youtube_name: 'Devtools Tech',
    data_channel_youtube_subscribe: 'true',
    data_channel_platform_link: '',
    data_channel_platform_resources_pages: [ '/questions', '/resources' ]

Loading IDE...