Fix wrong defaults in normalizeSettings
normalizeSettings|| while hydrating UI settings, and the bug stayed invisible until real saved values showed up. Now 0, an intentionally blank subtitle, and false keep getting overwritten by defaults. Fix the helper so only truly missing values fall back.normalizeSettings({ retryCount: 0, subtitle: '', emailOptIn: false }) // { retryCount: 0, subtitle: '', emailOptIn: false }
normalizeSettings({ retryCount: undefined, subtitle: null, emailOptIn: undefined }) // { retryCount: 3, subtitle: 'Untitled', emailOptIn: true }Public interview reports
These public, self-reported interview accounts informed this practice version. The exercise is modelled on reported rounds, not copied from them, and the reports are not verified official questions or endorsements.
- Taro: Capital One senior frontend engineer interview, 2024
The case round asked to find a bug in a budgeting program written by an intern, in Java, C++, Node.js or Python, without coding the fix. This drill practises finding a defaults bug in a teammate's helper; it is not the reported code.
Reported in a public Capital One interview account. Capital One frontend interview questions
Solution
The fixed code
export default function normalizeSettings(settings){
return {
retryCount: settings.retryCount ?? 3,
subtitle: settings.subtitle ?? 'Untitled',
emailOptIn: settings.emailOptIn ?? true
};
}
Similar questions
Guides
Preparing for interviews? Use Frontend Coding Challenges first, then move into a concrete Study Plan before targeted Company Prep.
Built in public
The code behind FrontendAtlas lives on GitHub. A star helps other frontend engineers find it.