Step-by-step working of current code for calculating loss and categories 1. Find the control group - Identifies the control group by searching for the row that starts with "C " in the 'tableJson' test data. - Extracts the values for revenue, conversions, and visitors for this control group. 2. Calculate control metrics - Earnings Per Click (EPC): Calculated by dividing revenue by visitors (EPC = revenue ÷ visitors). - Conversion Rate (CR): Calculated by dividing conversions by visitors (CR = conversions ÷ visitors). 3. Check each variation (variant) - For each variant row: - Extracts the values for revenue, conversions, and visitors. - Calculates EPC and CR for the variant. - Calculates the EPC difference: control EPC - variant EPC. - Calculates the Revenue Loss: EPC difference × visitors. This represents the potential money lost if the variant were to run instead of the control. - Accumulates totals: Sums up all revenue losses. Compares expected conversions to actual conversions to determine the total conversion loss. 4. Check statistical significance - Uses a 95% confidence interval (z = 1.96). - Requires a business-defined Minimum Detectable Effect (MDE) of at least 5% impact. - A variant's difference is marked as important if it is both statistically significant and exceeds the MDE. - A variant is a positive impact if it is better than the control. - A variant is a negative impact if it is worse than the control. 5. Decide the test category - "Tests to Accept/Implement": Assigned if only positive variants are found. - "Tests to Turn Off": Assigned if only negative variants are found. - "Undecided Tests": Assigned if there is a mix of positive and negative variants or the results are unclear. 6. Build summary strings - Converts numerical data into human-readable strings, such as "Control conversions: 100/200," "Variant A CR: 12.50%," and "Impact: -5.20%." - Outputs a summary including total conversions, gained/lost conversions, and monetary impact ($ lost or gained).