'How to access a specific value in array

I want to access each element of my "to" value of the children property in my array.

const items = [{
  name: 'Administrateur',
  children: [
    {
      name: 'Catalogue',
      to: 'catalogue'
    },

and function :

 function openRoute() {
  items.forEach(item => {
  const route = item.children.values(?? idk)   })
}

thank you for your help



Solution 1:[1]

You should first access to the items array and then get into children array.

items.forEach(item => item.children.forEach(child => child.to));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1