Javascript: Taking the highest 2 numerical values out of a series of 4 possible values.
- by Bodhi
What I'm trying to do is to take the highest two values out of 4 possible variables and add them together, while ignoring the lesser two values. My values will be anywhere between 1 and 5.
So, for example, if I have Trait1, Trait2, Trait3 and Trait4 with the following assigned values: 3, 3, 2, 1, the script will pick up the 3 and the 3, but not the 2 and the 1. If I change the values around so that I have 4, 3, 1, 5, the script will pick up the 4 and the 5, but not the 3 and the 1. How would I go about doing this?
Thank you in advance.