score = (x) -> if x == "Yes" 10 else 0 weights = [0.25, 0.25, 0.25, 0.25] anti_bribery_anti_corruption = [policy, process, in_contractual_agreements, compaint_mechanism] weights.reduce((weighted_sum, weight, index) -> weighted_sum + weight*score(anti_bribery_anti_corruption[index]) , 0)