Code AnalysisIntermediate 60s
Strategy gone wrong: enum switch
function price(tier: Tier) {
switch (tier) {
case 'A': return 0.1;
case 'B': return 0.2;
case 'C': return 0.3;
}
}
// Adding tiers now requires editing this function and every similar switch.
What is the most likely refactor to reduce the OCP pain?
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.