Kyva :veenk_logo: on Nostr: Recursividad, antes la evitaba, ahora la busco 👉👈 const propIsTrue = (obj, ...
Recursividad, antes la evitaba, ahora la busco 👉👈
const propIsTrue = (obj, prop) => {
const [head, ...tail] = prop.split(".");
if (tail.length === 0) return obj[head] === true || obj[head] === 1;
if (!obj[head]) return false;
return propIsTrue(obj[head], tail.join("."));
};
const test = propIsTrue(
{
finances: {
customDonation: {
bankTransfer: true,
},
},
},
"finances.customDonation.bankTransfer"
);#dev
const propIsTrue = (obj, prop) => {
const [head, ...tail] = prop.split(".");
if (tail.length === 0) return obj[head] === true || obj[head] === 1;
if (!obj[head]) return false;
return propIsTrue(obj[head], tail.join("."));
};
const test = propIsTrue(
{
finances: {
customDonation: {
bankTransfer: true,
},
},
},
"finances.customDonation.bankTransfer"
);#dev