I have an array formatted like so
const array = [
['technology', 'apple', 'computers', 'macbook_pro'],
['technology', 'apple', 'computers', 'macbook_air'],
['technology', 'apple', 'phones', 'iphone'],
['technology', 'samsung', 'phones', 'Galaxy S21'],
]
And I need to convert it to an object formatted like so:
{
technology: {
apple: {
computers: {
macbook_pro: {},
macbook_air: {}
},
phones: {
iphone: {}
}
},
samsung: {
phones: {
galaxy_s21: {}
}
}
}
}
I tried getting it done with a two forEach loops but I keep getting stuck.