Company: Cashfree_6nov_MCQ
Difficulty: medium
Analyze the following code snippet, identify the problem and choose the best refactoring technique. function printOvertimeRate(hours, rate){ // Calculate total hours worked let sum = 0; for(let i = 0; i < hours.length; i++){ sum += hours[i]; } let overtime; if(sum > 40){ overtime = sum - 40; } else { overtime = 0; } // Calculate the overtime rate let overtimeRate; if(overtime > 0) { // ... logic ... } } Comments are too short, unhelpful, and will confuse any future developer. Rewrite the comments to be more descriptive. The for loop to calculate the sum is unnecessary. Use JavaScript's reduce method to calculate the sum. Replace lengthy conditionals with switch statements. The function has too many concerns. Extract the concerns into multiple functions. Given the equation a+b*c-d in infix notation, use the following algorithm to change it to postfix notation. Notes: Multiplication is a higher priority than addition and subtraction. The variables a, b, c, and d are operands. Th