function removeDuplicates(menuArray) {
let flatmenus = menuArray.flat();//This method combines child and parent arrays into one unique array
let combinedMenu = new Set();//Creates an object that removes duplicate elements
flatmenus.forEach(dish => { //Adds elements from Flatmenus to the newly created Object Set()
combinedMenu.add(dish)
});
const menuCombined = document.querySelector('#combined-menu')
for (let dish of combinedMenu) {
let foodNode = document.createElement('li')
foodNode.innerText = dish;
menuCombined.appendChild(foodNode);
}
}
removeDuplicates([["Tacos", "Burgers"], ["Pizza"], ["Burgers", "Fries"]])
Why can't a for..in loop handle the object but it works fine with Set()? Doesn't Set() return an Object?