score = (x) -> if x == "Yes" 10 else 0 redistributed_weights = (weights, values) -> num_of_weighted_values = weights.length for value, index in values if value == "Not Applicable" num_of_weighted_values -= 1 redistributed_weight_value = weights[index] for weight, i in weights if weight == 0 continue weights[i] = weight + redistributed_weight_value/num_of_weighted_values weights[index] = 0 weights weights = [0.15, 0.15, 0.25, 0.15, 0.15, 0.075, 0.075] plastic_use_and_waste = [reduction_qualitative_evidence, reduction_quantitative_evidence, reduction_targets, plastic_use_reporting, plastic_waste_reporting, reduction_evidence_upstream, reduction_evidence_downstream] redistributed_weights(weights, plastic_use_and_waste) weights.reduce((weighted_sum, weight, index) -> weighted_sum + weight*score(plastic_use_and_waste[index]) , 0)