const prefix = 'user';
const id = 42;
const role = 'admin';
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);
const profile = {
[`${prefix}_${id}`]: 'Marcus',
[Symbol.iterator]: null,
[`get${capitalize(role)}`]: () => 'full-access',
[`${prefix}Count`]: 3,
};
const dynamicKey = `${prefix}_${id}`;
console.log(
profile[dynamicKey],
profile[`get${capitalize(role)}`](),
profile[`${prefix}Count`] * id,
Object.keys(profile).length
);
Post #3150
2.53K
CHALLENGE
- ❤ 2