set
by John Wick
JavaScript
const merchant = {
id: "4cb294eb-09e6-4355-93f5-c7f429d66350",
merchant_id: "de6ba9f0-5c4f-42d5-a8f2-e62ddeecb3b8",
pin: true,
title: "Sarah Collective 4",
created_at: "2024-09-27T10:29:30.735Z",
address: "300 Creekside Ave, Albany, NY 14214",
marker: null,
active: true
};
function convertToSet(obj, keys) {
const values = keys.map(key => obj[key]).filter(value => value !== undefined);
return new Set(values);
}
// Define the keys you want to include in the Set
const outputSet = convertToSet(merchant, ["id"]);
// Test output
console.log('outputSet:', outputSet);