My goal is to merge all the important values from the objects in this array.
var currentInventory = [
{
name: 'Brunello Cucinelli',
shoes: [
{name: 'tasselled black low-top lace-up', price: 1000},
{name: 'tasselled green low-top lace-up', price: 1100},
{name: 'plain beige suede moccasin', price: 950},
{name: 'plain olive suede moccasin', price: 1050}
]
},
{
name: 'Gucci',
shoes: [
{name: 'red leather laced sneakers', price: 800},
{name: 'black leather laced sneakers', price: 900}
]
}
];
The desired output should be:
[
['Brunello Cucinelli', 'tasselled black low-top lace-up', 1000],
['Brunello Cucinelli', 'tasselled green low-top lace-up', 1100],
// ...
]
I have written the following code:
function renderInventory(inventory) {
const arr = [];
for (var i = 0; i < inventory.length; i++) {
for (var n = 0; n < inventory[i].shoes.length; n++) {
arr.push([inventory[i].name + ', ' + inventory[i].shoes[n].name + ', ' + inventory[i].shoes[n].price]);
}
}
return arr;
}
Unfortunately, it currently gives me:
[
['Brunello Cucinelli, tasselled black low-top lace-up, 1000'],
['Brunello Cucinelli, tasselled green low-top lace-up, 1100'],
...
]
I'm unsure how to adjust my code so that each element is wrapped in quotations, rather than the entire array.