let lists = ["Grocery", "Clothing", "Furniture"];
let items = [
[
"tomatoes",
"cheese",
"bread",
"ham"
],
[
"shirt",
"jacket",
"jeans"
],
[
"sofa",
"carpet",
"bed"
]
];
These two arrays are connected in a way that 'items' arrays are associated with each item in the 'lists' array. For instance, items[0] corresponds to lists[0], and so on.
I attempted to extract the longest string from the arrays, but my approach failed...
let longestString = (list) => {
lists[items.reduce((a, b) => a.length > b.length ? a : b)];
}
console.log(`The longest item in Clothing category is: ${longestString("Clothing")}`)