score = (x) -> if x == "Yes" 10 else 0 weights = [0.25, 0.25, 0.25, 0.25] water_n_sanitation = [right_to_water, preventing_risks, requiring_business_partners_to_respect_right, improving_business_partner_practices] weights.reduce((weighted_sum, weight, index) -> weighted_sum + weight*score(water_n_sanitation[index]) , 0)