September 10th, 2024
What's missing in this code?
const addAffixes = createAffixer('pre-', '-suf');
console.log(addAffixes('fix')); // pre-fix-suf
const chainAffix = addAffixes.prefix('super').suffix('ed');
console.log(chainAffix('fix')); // superpre-fix-sufed
function createAffixer(
initialPrefix = '',
initialSuffix = ''
)
const affix = (str) =>
return initialPrefix + str + initialSuffix;
};
affix.prefix = (newPrefix) => {
return createAffixer(
,
);
};
affix.suffix = (newSuffix) => {
return createAffixer(
,
);
};
return affix;
}
Type or select from these options